301 redirect with htaccess

htaccessHow to redirect web based page with .htaccess
Following are the code to paste (be careful to write on .htaccess it can be messed up whole website if anything goes wrong) into .htaccess file 301 redirection for any domain :

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.olddomain.com
RewriteRule ^(.*)$ http://www.newdomain.com [R=301,L] newdomainRewriteRule ^$ http://www.newdomain.com [R=301,L] RewriteRule ^index.htm$ http://www.newdomain.com [R=301,L] RewriteRule ^index.php$ http://www.newdomain.com [R=301,L] RewriteRule ^index.html$ http://www.newdomain.com [R=301,L] RewriteRule ^index.shtml$ http://www.newdomain.com [R=301,L] RewriteRule ^index.asp$ http://www.newdomain.com [R=301,L] RewriteRule ^default.asp$ http://www.newdomain.com [R=301,L] RewriteRule ^index.aspx$ http://www.newdomain.com [R=301,L] RewriteRule ^index.cfm$ http://www.newdomain.com [R=301,L] RewriteRule ^index.pl$ http://www.newdomain.com [R=301,L] RewriteRule ^default.htm$ http://www.newdomain.com [R=301,L]

Like to share it

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *