301 Redirections
When a internet user of Search Engine spider browses for an URL, the web server where the page is hosted checks a file called ‘.htaccess’. This ‘.htaccess’ file can be modified so that it tells browsers and or spiders that the website or web page has either temporarily moved (302 redirect) or permanently moved (301 redirect). From an SEO perspective, 301 redirects are the only search engine friendly way to redirect URLs.
Wondering how to insert a 301 redirect? Below are methods to implement 301 URL redirection (on Linux servers with Apache Mod-Rewrite module enabled):
Redirect Old domain to New domain
Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain. The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed).
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Please REPLACE www.newdomain.com in the above code with your actual domain name.
Redirect to www-version
Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com. The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed).
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Please REPLACE domain.com and www.newdomain.com with your actual domain name.

