my case: i have 2 domains (i.e. domain1.com and domain2.com), one is the normal hosting-package domain (domain1.com), the other one is a parked domain. they both use the same root-directory, but different php-files.. (for domain1.com is is called d1, for domain2.com d2) .. no php-extension due to the SEO-domain-style (menuepoints have links like this: www.domain2.com/d2/article/summer)
i have so far a php solution, but this is not very search-engine-friendly.
well, my mod_rewrite script so far:
- Code: Select all
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/d2(/.*)?$
RewriteRule ^(.*)$ /d2$1 [R=301,L]
one of the 10 million scripts i tried and it doesn't work. i tried to write something that also recognizes if there is already a d2 behind the URL and also checks if the URL is written with www or without.. it MUST take always the d2 if the URL is domain2.com, same for domain1 ..
can anybody help?
to make this work in domain1 also, will it be ok to duplicate the code without the RewriteEngine on while changing the variables (domain2.com > domain1.com, d2 > d1)?
thanks for your help...