how to make 301 redirect
Filed in Development on Dec.08, 2008
Assuming you want to forward old traffic from old domain olddomain.com to new domain newdomain.com, use the following .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule (.*) https://www.newdomain.com/$1 [R=301]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
</IfModule>
Tags: apache, mod_rewrite