Sunday, November 20, 2011

9:01 AM
4

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

4 comments:

Online Works For All said...

100% Free Data Entry Jobs Available!

http://bestaffiliatejobs.blogspot.com/2011/07/earn-money-online-by-data-entry-jobs.html

sathya said...

Great article.Great content.It is very informative.It is helpful to me.please update it .Thanks for sharing.

Joomla developer

shalini said...

Domain name It associates different information with domain names assigned to each of the participants. Domain names are also used as simple identification labels to indicate ownership or control of a resource.
purchase domain name

domina said...

Thanks for the information you shared here..
Buy domain names