Posted By

beneberle on 07/16/10


Tagged

redirect htaccess


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

NARKOZ
tre
kubaitis
JCFreak1223
benediktvaldez
345crew


.htaccess URL Rewrites


 / Published in: Apache
 

This is good for ensuring your domain is always either accessed with or without the www, which is important for SEO. It is also good if you have multiple domains that should resolve to the same site, and can redirect all requests to the main domain.

  1. # This chain of rules will rewrite old-domain, www.old-domain, and new-domain to www.new-domain
  2.  
  3. rewriteCond %{http_host} ^old-domain\.com$ [OR]
  4. rewriteCond %{http_host} ^www.old-domain\.com$ [OR]
  5. rewriteCond %{http_host} ^old-domain\.org$ [OR]
  6. rewriteCond %{http_host} ^www.old-domain\.org$ [OR]
  7. rewriteCond %{http_host} ^new-domain\.com$ [NC]
  8. rewriteRule ^(.*)$ http://www.new-domain.com/$1 [r=301,L]

Report this snippet  

You need to login to post a comment.