Forum Moderators: phranque
Trouble is, my host automatically allows all directories to be accessed as subdomains with no configuration jiggery-pokery needed, i.e. [sub.domain.org...] -> [domain.org...] are both the same.
When I use the method of .com -> .org redirection above, I no longer can use the subdomain in the same way (they still operate they're just always redirected to the folder-based URL).
Additionally, certain directories I limit access as per IP via mod_rewrite. When [domain.org...] is requested via [limitedaccess.domain.org...] it removes it from the IP exclusion rule, redirecting to the subdirectory because the REQUEST_URI checks out. I would prefer to not have to write two rules for every directory I'd like to protect... any ideas?
You do do several things to fix this:
1) Have the host point all subdomains to your "main" root directory, and use your *own code* in .htaccess to sort the subdomains into subdirectories *after* applying your global IP and user-agent restrictions.
2) Put a copy of your .htaccess code in each subdomain's subdirectory.
3) Use symbolic links to "share" one .htaccess file across multiple subdirectories.
In the latter two cases, the .htaccess code must be written carefully so that it is usable in multiple subdomains/subdirectories. Method #3 might not work -- I've never had to try it myself.
I do use method #1 myself to implement "test" subdomains on several sites. It's described in msg #6 this recent thread on rewriting arbitrary subdomains to subdirectories [webmasterworld.com].
Jim