rewrite or
I found this code for Apache rewrite:
Canonical Hostnames
Description:
The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of
www.example.com instead of example.com, you might use a variant of the following recipe.
Solution:
# For sites running on a port other than 80
RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*)
http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R]
# And for a site running on port 80
RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*)
http://fully.qualified.domain.name/$1 [L,R]
Also, I found this code:
Add this to your zone file for that website:
Code:
www IN CNAME website.com
And this for the .htaccess file:
RewriteEngine on
RewriteCond % {HTTP_HOST } ^website\.com$ [NC]
RewriteRule ^ (.*) $
http://www.website.com/$1[R=301,L]
Here are 3 different codes, not sure at this point which to do.
Mark