View Single Post
  #1 (permalink)  
Old 03-02-2009, 04:57 PM
desbest's Avatar
desbest desbest is offline
Member
Latest Blog:
None

 
Join Date: 02-17-06
Posts: 31
iTrader: 0 / 0%
desbest is liked by many
I can point subdomains to subfolders, but not sub-subfolders

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

Code:
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} ^([^.]+)\.hostingz\.org(: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]
What that code does is redirect http://subdomain.hostingz.org to http://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 http://subdomain.hostingz.org --> http://hostingz.org/sites/subdomain.

How can it be done? And test it out first as the examples below do not work.
Code:
RewriteRule sites/^(.*) /%1/$1 [L]
or
Code:
RewriteRule sites^(.*) /sites/%1/$1 [L]
Code:
RewriteRule ^(.*) /sites/%1/$1 [L]
__________________
I do as I say, and I say what I do, I say what is right, and I do what is true.
Life is good once you do as you know it should.
Reply With Quote