HostOnNet Blog

Redirect OLD domain to NEW using .htaccess

When you move your web site form one domain to another, you need to redirect all visitors on your old domain to new one to avoid lose of traffic. Google recommend using 301 redirect when you change URL of a web page.

To do this create .htaccess file with following content.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^OLD-DOMAIN.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.OLD-DOMAIN.com$
RewriteRule (.*)$ http://www.NEW-DOMAIN.com/$1 [R=301,L]

If you only need to redirect few page on your web site, use Redirect option.

Redirect 301 /old-page.html http://www.new-domain.com/new-page.html

See Htaccess Tips and Tricks


Posted in Apache