
Originally Posted by
ademmeda
Thanks for your comment David. I am afraid I didn't understand this part: "albeit I'd recommend regex of .? and redirection which replaces /$1 with %{REQUEST_URI}"
ademmeda,
The use of (.*) can cause problems (generally, looping code) but the difference between Apache 1.x and Apache 2.x can also cause problems. The best reason to merely match anything then redirect to the %{REQUEST_URI} is that it already exists!
Better yet, your other code can be combined (or deleted) as you don't need the redirection to domain.com in the maindomain's .htaccess if you're using
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule .? http://www.domain.com%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www.domain.maindomain\.com
RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=permanent,L]
RewriteCond %{HTTP_HOST} ^domain.maindomain\.com
RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=permanent,L]
OR merely
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} !www\.domain\.com$
RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=301,L]
Since what you want is www.domain.com, this will redirect only if not www.domain.com and it will then leave the {REQUEST_URI} (as seen in the domain's directory) alone.
Regards
DK
Bookmarks