I can point subdomains to subfolders, but not sub-subfolders. How can I?

Discussion in 'Apache' started by desbest, Mar 1, 2009.

  1. #1
    I can point subdomains to subfolders, but not sub-subfolders. How can I?

    
    RewriteEngine on
    
    
    # Rewrite <subdomain>.example.com/<path> to example.com/<subdomain>/<path>
    #
    # Skip rewrite if no hostname or if subdomain is www
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    # Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
    RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.[B]hostingz[/B]\.[B]org[/B](:80)?<>/([^/]*) [NC]
    # Rewrite only when subdomain not equal to first path element (prevents mod_rewrite recursion)
    RewriteCond %1<>%3 !^(.*)<>\1$ [NC]
    # Rewrite to /subdomain/path
    RewriteRule ^(.*) /%1/$1 [L] 
    
    
    Code (markup):
    What that code does is redirect httpX://subdomain.hostingz.org to httpX://hostingz.org/subdomain. And it works!

    But how do I modify the last line, the RewriteRule so that it redirects to sites/(then the subdomain).

    So httpX://subdomain.hostingz.org --> httpX://hostingz.org/sites/subdomain.

    How can it be done? And test it out first as
    
    RewriteRule sites/^(.*) /%1/$1 [L] 
    Code (markup):
    or
     RewriteRule sites^(.*) /sites/%1/$1 [L] 
    Code (markup):
    Both does not work.
     
    desbest, Mar 1, 2009 IP