/ 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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# This chain of rules will rewrite old-domain, www.old-domain, and new-domain to www.new-domain rewriteCond %{http_host} ^old-domain\.com$ [OR] rewriteCond %{http_host} ^www.old-domain\.com$ [OR] rewriteCond %{http_host} ^old-domain\.org$ [OR] rewriteCond %{http_host} ^www.old-domain\.org$ [OR] rewriteCond %{http_host} ^new-domain\.com$ [NC] rewriteRule ^(.*)$ http://www.new-domain.com/$1 [r=301,L]