Forum Moderators: phranque

Message Too Old, No Replies

com -> org rewrite plus subdomains

         

compooter

10:35 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



I have the exact setup as jdmorgan's earlier post [webmasterworld.com] (msg #9) on a now-deprecated forum. I have a domain.com set to point directly to domain.org's public_html. His method works wonderfully for rewriting all requests for .com -> .org.

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?

jdMorgan

11:04 pm on Jul 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand what you posted, it sounds like the hosting service's redirection is done directly to the sub-folder, and bypasses your "root-level" .htaccess file. One could argue that this is correct, since the sub-folder *is* the root-level directory for that sub-domain. As a result, requests to subdomains never activate your main .htaccess file, leading to the problems you describe.

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