Redirecting URLs with .htaccess

If you move the location of your website you should also provide a 301 redirect, letting search engines and end users know that the URL for your site has changed. This can also be useful to make sure all references are made without a www prefix, for example.

In Apache, with Mod Rewrite enabled, add the following three lines to a .htaccess file in the directory that used to contain the page. Note that in an FTP client you may have to enabled viewing hidden files to see .htaccess.

RewriteEngine on
rewritecond %{http_host} ^www\.domain\.com [nc]
rewriterule ^(.*)$$1 [r=301,nc]