Remove WWW'sOriginal posted by: Admin on 28-01-2007This tutorial will teach you a method of forcing all your visitors to look at 'domain.com' instead of 'www.domain.com' or vise-versa. This will tell us what version of our site the visitor is looking at. For example if they are looking at 'http://www.thecoder.com.au' the HTTP_HOST will print 'www.thecoder.com.au' if they are looking at the non-www version then it will print 'thecoder.com.au'. So with this we can write a simple little script to check what the start of the string looks like With that simple if statement we can discover what version they are looking at, now all we have to do is redirect the visitor. So now if the visitor goes to the WWW version of the site they will be redirected to the new version. This script can be placed up the top of any of your pages, or if you want it can go into a general config file and even placed within a function.
|
|
|||||