SEO: Redirecting users from your www subdomain to the non-www domain

One of the major things people don’t understand about Search Engine Optimization (SEO) is that google assigns a PageRank per URL. So if you have a friend who links to www.yourpage.com/some_content and another friend that links to http://yourpage.com/some_content, google doesn’t combine them and acts as if one person is linking to each page.

However, if, when crawling your page, the googlebot is redirected via a 301 Moved Permanently, the googlebot learns that the two pages are the same. This is incredibly easy to do if mod_rewrite is enable on your Apache installation.

To do this, open up the .htaccess for your site and add these lines:

# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.yourpage.com/... will be redirected to http://yourpage.com/...)
# adapt and uncomment the following:
RewriteCond %{HTTP_HOST} ^www\.yourpage\.com$ [NC]
RewriteRule ^(.*)$ http://yourpage.com/$1 [L,R=301]

Remember to replace “yourpage.com” with your actual URL. This redirect/rewrite will preserve the query so www.yourpage.com?article=5 will still get translated to http://yourpage.com?article=5.

Be Sociable, Share!

No related posts.

No Comments.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>