Forum Moderators: phranque
This is a snippet from my current .htaccess file:
# this ruleset converts .co.uk to .com
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co.uk [NC]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ [domain.com...] [R=301]
What I'd like to do is to add a RewriteRule to force the inclusion of the www. in the address so that [domain.com...] translates to [domain.com....]
Could you help, please?
Thanks in advance. ;-)
Just [OR] in another RewriteCond:
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.c[b]o\.u[/b]k [NC[b],OR][/b]
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ http://www.domain.com/$1?%1 [R=30[b]1,L][/b]
Note the other minor changes, too.
You shouldn't actually have to explicitly carry forward the query string -- This should happen automatically unless you explicitly clear the query string in your RewriteRule. So you might try just using:
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk [NC,OR]
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Jim