How to Redirect to www with (301 redirect) using mod_rewrite for a better web site SEO

Monday, 19th July 2010

For a better website SEO it’s recommended that you think of rewritting all your incoming http://yourdomain.com to http://www.yourdomain.com. That way you will escape from having a duplicate webpage content.
Still many websites online are not aware that having their website content available twice whenever accessing both http://yourdomain.com and http://www.yourdomain.com is a terrible practice since it’s very likely that (Google, MSN, Bing) Web Crawlers will crawl and try to index the content of the website, seing that the content is twice available, they will rank the website as a website with a duplicate content and that will have a direct influence on the overall site pagerank.
One of the possible ways to redirect your incoming requests to yourdomain.com to go to www.yourdomain.com is via a mod rewrite rule within your .htaccess file
For the rule to work make sure that the <Directory> for the VirtualHost of your website has in it included the Apache directives

AllowOverride All

As you assure yourself mod rewrite is correctly enabled for your domain then edit your .htaccess and place in it:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.pc-freak.netRewriteRule (.*) https://www.pc-freak.net/$1 [R=301,L]

Of course you will have to replace the www.pc-freak.net domain in above example with the your custom domain name.
Now all your incoming Apache requests for domain www.pc-freak.net will be automatically using the 301 Redirect

Here it is important to explain that the 301 redirect is the most efficient and Search Engine Friendly redirect option for a webpage redirect.

The code “301” is interpreted by the web crawlers as “moved permanently”. In other words the content of the previous website is moved permanently to the one where the redirect leads.
Of course there are many other possible ways to implement the 301 redirect, however using mod_rewrite potential is probably the most efficient one for a dynamic site content.

Share this on:

Download PDFDownload PDF

Tags:

One Response to “How to Redirect to www with (301 redirect) using mod_rewrite for a better web site SEO”

  1. Brianna Lee says:
    Google Chrome 4.0.221.7 Google Chrome 4.0.221.7 Windows 7 Windows 7
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.7 Safari/532.2

    website SEO is a very time consuming task,`*

    View CommentView Comment

Leave a Reply

CommentLuv badge