Redirect www to non-www URLs

Over the years as a web developer I have setup many websites that needed to be modified for SEO (Search Engine Optimization). For SEO purposes, it is best to keep all your urls on your site and that point to your site either with www or without a www before the domain. One of the standards that has evolved over the years is having urls with www in them. If you go to any of the major tech industry websites like,,, etc. you will notice that they all redirect you to their version rather than just However, this is more of a convention and it is not required and both versions are acceptable.

You will want to redirect to either one or the other but in this article I will explain how to redirect visitors to your non-www version.