Many sites map a variety of hostnames to the same content. For example, example.com, www.example.com and www.example.net may all refer to the same site. It is best to make sure that, regardless of the name clients use to access the site, they will be redirected to a single, canonical hostname, preferably without "www.". This makes the site easier to maintain and assures that there will be only one version of the site in proxy caches and search engines.
Using Virtual Hosts
Use the Redirect directive inside a
VirtualHost block to force browsers to redo a request with a new host name.
Remember that the first listed
VirtualHost will serve all requests that match no
ServerAlias. By using a Redirect in this host, you can assure that any non-matched names will also be transferred to the Canonical host.