- Home
- Blogs
- George Boobyer's blog
- To www or not to www
To www or not to www
One of the trends these days is to lose the www. from your domain name.
Arguments for are usability (e.g. you don't have as much typing to do - it is easier to not have to say dubyadubyadubya every time you give out your web address).
There are counter arguments of course to do with cookie control and sites that have sub-domains etc.
What is important though is that you choose one and stick to it. In any event you should decide for one and not allow both.
Supporting both will cause duplicate content in Google and you may suffer in SEO terms.
To pick one - simply go to the .htaccess file and uncomment and update the option you would like.
e.g. to redirect all traffic to http://example.com to http://www.example.com
# To redirect all users to access the site WITH the 'www.' prefix, # (http://example.com/... will be redirected to http://www.example.com/...) # adapt and uncomment the following: RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
e.g. to redirect all traffic to http://www.example.com to http://example.com do the reverse
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
By way of explanation the following elements mean:
- RewriteCond
- This is a line that says anything that meets this criterion will have the following RewriteRule applied.
- %{HTTP_HOST}
- Checks the host of the incoming request
- ^www\.example\.com$
- says if the host starts with www.example.com then the match is true.
- $
- The $ indicates the end of the criterion.
- [NC]
- says ignore case. In older versions of ISAPIREWRITE for windows this used to be [I].
- RewriteRule
- The rewrite rule - anything that meets the condition will have the following rule applied
- ^(.*)$
- IN this case the rule uses a regular expressions for 'everything' so every request will be matched of it meets the condition
- http://example.com/$1
- Send every request to the domain without the www. and keep the full path. This means that http://www.example.com/mypage.htm will be redirected to http://example.com/mypage.htm. The (.*) becomes a parameter that you can use and is substituted for the $1 in this case (the first parameter)
- [L,R=301]
- The L says this is the last rewrite rule and don't process any more.
- [L,R=301]
- The R=301 says issue a 301 HTTP redirect Permanently moved - this encourages the client to update their references for this path. e.g. a search engine should update the index entry.
A lack of www. can be attractive and simpler to convey - but be aware that some modules such as XML sitemap will append www. in any case and that will make your sitemap incompatible with webmaster tools sitemap submission.
If you are using Google Analytics (and if not why not?) you can specify which 'pattern' your site should use - which in theory will make Google dedupe your indexing.
Other things to consider:
If you change the default remember to update the basepath in your settings.php
Contact Details
Blue-Bag Ltd
- info [at] blue-bag.com
- Telephone: 0843 2894522
- Blue-Bag HQ:
The Garage, Manor Farm
Chilcompton, Radstock
Somerset, BA3 4HP, United Kingdom - Telephone: (+44) 01761 411542
- Blue-Bag Brighton:
Unit 35 Level 6 North, New England House
New England Street, Brighton
BN1 4GH United Kingdom - Telephone: (+44) 07944 938204
- VAT GB 748125034
- UK Company Reg: 3932829