Mobile app version of vmapp.org
Login or Join
Sue5673885

: 301 Redirect not behaving like I am wanting it too. What is my mistake? 301 Wildcard. I don't think I am doing it right. Need domain1.com/keyword5 to go to domain2.com/keyword5. Instead it does

@Sue5673885

Posted in: #301Redirect #Drupal #Seo

301 Wildcard. I don't think I am doing it right. Need domain1.com/keyword5 to go to domain2.com/keyword5. Instead it does this:
domain1.com/keyword5 goes to domain2.com (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/" [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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sue5673885

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

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 ^(.*)$ www.domain2.com/ [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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme