WCM tip #4: Use canonical domain name for your website


It is a good practice to have your website work with both www and non-www domain (ie. http://mavention.com vs. http://www.mavention.com) domain. Only one of those domains however should be defined as canonical domain for your website.

Often websites work either with or without the www. prefix but not with both. Using the non-preferred URL causes the visitor to be redirected to the home page (disregarding the URL path) or in the worst case it doesn’t open the website at all. It is a good practice to have your website work as expected no matter if the URL does or does not contain the www. prefix.

To optimize your website for Internet search engines all content of your website should be accessible via one URL only. This allows you to control how your website is indexed by Internet search engines and get the most of their ranking. Implementing support for www and non-www domains in your website theoretically makes the content of your website available via two URLs. The trick is to choose one domain as your canonical domain and have the other return a 301 Permanently Moved response and redirect the visitor to same page but then on the preferred domain.

Others found also helpful: