|
Posted by =?iso-8859-1?Q?Kim_Andr=E9_Ake on August 11, 2006, 4:43 am
Please log in for more thread options
Russell Hoover wrote:
>
> I want "www." to never show in a browser's location bar when anyone
> visits my site via my domain-name. i.e. :
>
> BAD: http://www.my-domain-name
>
> GOOD: http://my-domain-name
>
> How can I efficiently (and always) remove the "www." when people, out
> of habit or because they think they need to, type
> "www.my-domain-name", so that only "my-domain-name" shows?
>
> Do I do this with some type of refresh or redirect meta header?
>
> And, can I do it so that nothing happens for those who type my domain
> name in correctly by leaving off the "www."?
If your host uses Apache with mod_rewrite, and allows you to use
.htaccess files, you can put the following in an .htaccess file in your
web root directory:
RewriteEngine On
RewriteCond % !^example.com$ [NC]
RewriteRule ^(.*) http://example.com/$1 [L,R=301]
This will redirect any hostname that isn't "example.com" (without www
in front) on that account to example.com (again, without the www).
The "R=301" means that it will send a permanent redirect (instead of a
temporary redirect).
--
Kim André Akerĝ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
|