Forum Moderators: phranque
My host suggested that she can setup the subdomains to have the current subdirectories as their root.
However, www.example.com/site1/ will still stop working, won't it? Is it possible to redirect all incoming requests to www.example.com/site1/<any page> to site1.domain.com/<any page>?
Externally redirect example.com/subdir/.* to subdir.example.com/.*
-and-
Internally rewrite subdir.example.com/.* to example.com/subdir/.*
The first steps "moves" your pages in the search engine listings, while the second step (or your host's suggested method) provides for the subdomain content's filesystem location.
Both of these functions can be implemented using mod_rewrite, which gives you control (independent of your host) over how the subdomain-to-subdirectory mapping is accomplished.
Note that there is a trick to implementing the above functions without creating an 'infinite' rewrite/redirection loop; You must check the server variable %{THE_REQUEST} in a RewriteCond to qualify the external redirection.
Jim
I am not very familiar at all with mod_rewrite, do you have any examples of what the external and internal rewrites would look like?
What would you suggest, btw, as far as handling the internal rewrite? Is it better to use the method you suggest, or to have the host set it up? If I use the method you suggest, does my host even have to do anything at all to setup subdomains?
If you elect to have the hosting company install the rewrite for you, or if you use a "control panel" to do it, then you won't be able centrally-manage your subdomain->subdirectory rewrites; Part of the code will be in httpd.conf --only accessible indirectly through the control panel or by asking the host to change it-- and part of the code will be in your main domain's .htaccess file. That's the only compelling argument I can make for the .htaccess approach.
Jim