Snippets, Tutorials

www vs. non-www 301 redirect

If you would like to force all your incoming URLs to have www at the front for SEO reasons, create an .htaccess file with the following content in the root directory of your website.

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

What is 301 redirect?

301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. It's not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it's the safest option. The code "301" is interpreted as "moved permanently".

Source: How to Redirect a Web Page

Recommend Book

[tags]301 redirect, htaccess, search engines, seo[/tags]

One thought on “www vs. non-www 301 redirect

Comments are closed.

Twitter
LinkedIn
YouTube
Instagram