Web development Birmingham

Ensure website URL displays with www.

If you have a website, for example www.scorchsoft.com and a user visits it without the www. before the url then you may find that you are able to still browse your website without the prefix ever being present or added. Though this isn't a major functional problem, there is a risk that search engines such as google will treat and index both addresses to the website as different sites even though the content is identical. 

One solution to this problem is to implement "url canonicalization", whereby you add a meta tag onto the duplicate pages to inform robots that they the non-www version of the address is in fact a duplicate. There is a more simple way if you are using an Apache web server, and it involves editing your websites .htaccess file.

To implement this reqrite rules, navigate to and edit, or create a/the file name .htaccess file in your website root. and add the following to it:

RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]

This  tells the server if someone visits mysite.com then they should be 301 redirected (hence [L,R=301]) to the www. version of your website and anything else within the url should be appended to the end (hence the /$1). As an example the first few lines of the Scorchsoft htaccess look like this:

RewriteEngine on
RewriteOptions Inherit
Options +FollowSymLinksRewriteCond

%{HTTP_HOST} ^scorchsoft.com [NC]
RewriteRule ^(.*)$ http://www.scorchsoft.com/$1 [L,R=301]


Did you find this article useful? Sharing is a great way to show support, and ensures that we can continue to create more quality articles:

Get a free quote