Home » , , , » Force WWW onto Domain Name URLs for SEO with .htaccess

Force WWW onto Domain Name URLs for SEO with .htaccess

Written By Unknown on Minggu, 20 November 2011 | 09.01


You can get to a website by typing http://mydomain.com or by typing http://www.mydomain.com. So should this matter to you as a developer? Yup. Google doesn’t like when you have duplicate content on a website.


To make sure that Google doesn’t consider the content, or traffic, to the ‘non-www’ and the ‘www’ versions the same, it’s a good idea to either force the www, or to force remove the www from the URL when people enter the site. This way no matter what people enter as the URL, the effect is the same to your site.

So which to use? It’s up to you. From personal experience I’ve found that business owners tend to want the www if givin the choice, where people that actually know what they’re talking about  like shorter URLs and prefer to remove the www. 

I HATE seeing the ‘www’, both in URLs, and while we’re at it in any type of advertising, business cards, etc. The ‘.com’ implies the ‘www’, duuuh.

Below is the code you’ll need to add to your .htaccess file to either remove or to add the www to the URL.

# ---------------------------------------------------------------------- # Start rewrite engine # ---------------------------------------------------------------------- <IfModule mod_rewrite.c>   RewriteEngine On </IfModule> # Option 1: # Rewrite "www.domain.com -> domain.com" <IfModule mod_rewrite.c>   RewriteCond %{HTTPS} !=on   RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]   RewriteRule ^(.*)$ http://%1/$1 [R=301,L] </IfModule> # ---------------------------------------------------------------------- # Option 2: # To rewrite "domain.com -> www.domain.com" uncomment the following lines. # <IfModule mod_rewrite.c> #   RewriteCond %{HTTPS} !=on #   RewriteCond %{HTTP_HOST} !^www\..+$ [NC] #   RewriteCond %{HTTP_HOST} (.+)$ [NC] #   RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L] # </IfModule>
 
 
code from html5boilerplate.com

Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger