Search This Blog

May 10, 2012

Web Development: Forcing WWW version of your domain

There's a difference between http://www.domain.com and http://domain.com especially in terms of Search engine optimization. You need to set up either you want to use a WWW or Non-WWW domain to avoid "www/non-www canonical issue". Google may index your site in two versions if you have missed to set up a canonical tag "<link rel="canonical" href="your main URL" />" and set up your preferred domain.

 Most of the popular content management system, such as Wordpress, automatically adds this on script on htaccess by setting your correct domain on the admin panel. So here’s the code that you need to add in your htaccess file.

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

The code above will for all your website url to use the WWW. So, in case user will access your site in the browser and type http://example.com. It will redirected to http://www.example.com. 

3 comments:

Jay20 said...

You gave nice ideas here. I done a research on the issue and learn most peoples will agree with your blog.

website design Boston

said...

your homepage is really helpful! thank you

Is there a possibility to get your help (for a fee of course) I'm having problems I couldn t resolve!

Regards

Désirée
losingforfashion.blogspot.com

Janz said...

@Jay20 - thank you!

@Desiree - thank you! Of course I love to. Please email me directly on janzell1989@gmail.com

regards,
Janzell