How to set permanent 301 redirect with htaccess?

.htaccess mod_rewrite 301 redirect help please?

  • Hi, I have more than 1 domain name for my site, I want all variations of both (i.e. domain2.com, www.domain2.com, domain1.com) to point to www.domain1.com this is what i have in my .htaccess file: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^domain2.com[NC] RewriteRule ^(.*)$ http://www.domain1.com/%241 [R=301,L] RewriteCond %{HTTP_HOST} ^www.domain2.com[NC] RewriteRule ^(.*)$ http://www.domain1.com/%241 [R=301,L] RewriteCond %{HTTP_HOST} ^domain1.com[NC] RewriteRule ^(.*)$ http://www.domain1.com/%241 [R=301,L] this does not appear to be working, anybody have any ideas what I might try? (I also tried RewriteCond %{HTTP_HOST} ^domain2\.com[NC] -it does not seem to have made any difference) thanks a lot.

  • Answer:

    Have you tried playing around with your DNS settings? This sounds like something that should be handled there. Mod_rewrites are usually for making URL extensions prettier. I believe you can adjust the A Name setting for the domains to point to domain1.com

Renegade at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.