Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

301 Wildcard. I don't think I am doing it right. Need to go to Instead it does this: goes to (tld, root, not the keyword5 directory)

Here is my .htaccess:

RewriteCond %{HTTP_HOST} ^domain1\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain1\.com$
RewriteRule ^(.*)$ "http\:\/\/www\.domain2\.com\/$1" [R=301,L]

PS: Can I do multiple domains on the same .htaccess? For example, I have 3 domains on the same public_html, can I 301 each of them like this?

share|improve this question
Your rule at a first glance seem ok to me, did you add RewriteEngine on before the rules in your .htaccess? – Marco Demaio Dec 24 '12 at 18:00
Regarding your "PS", yes you can! – Marco Demaio Dec 24 '12 at 18:01

1 Answer 1

Your .htaccess actually looks OK-ish to me, in that it should work, although it can be simplified:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$
RewriteRule ^(.*)$$1 [R=301,L]

The RewriteRule substitution is a string, not a regex, so no need to escape everything. In fact you never need to escape forward slashes in .htaccess. No need for the double quotes either.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.