htaccess Redirect all http requests to new domain

Redirect from olddomain.com to newdomain.com:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]

This is useful when using www.newdomain.com as your new domain name
Redirect from olddomain.com to www.newdomain.com:

RewriteEngine On
RewriteCond %{HTTP_HOST} !olddomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

One thought on “htaccess Redirect all http requests to new domain

Leave a Reply

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