Click here to get back home

Removing "www." from location bar?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Removing "www." from location bar? Russell Hoover 08-11-2006
Get Chitika Premium
Posted by Russell Hoover on August 11, 2006, 3:27 am
Please log in for more thread options



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."?

--
// rj@panix.com //
City cops & state cops & national guard & bureau cops & tv cops & movie cops
& uniform & plainclothes cops & riot cops & cops on top of cops on top of
cops on top of cops: it's a world full of cops. -- Paleface

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)

Posted by Steven Saunderson on August 11, 2006, 7:03 am
Please log in for more thread options


On 11 Aug 2006 08:43:43 GMT, Kim André Akerĝ

> RewriteEngine On
> RewriteCond %        !^example.com$ [NC]
> RewriteRule ^(.*)        http://example.com/$1 [L,R=301]

Kim, I don't think this will work for requests other than the default
page. An alternative might be :

RedirectMatch permanent ^www.(.*) http://$1

--
Steven

Posted by Richard Gration on August 11, 2006, 7:36 am
Please log in for more thread options


On Fri, 11 Aug 2006 21:03:25 +1000, Steven Saunderson wrote:

> On 11 Aug 2006 08:43:43 GMT, Kim André Akerĝ
>
>> RewriteEngine On
>> RewriteCond %        !^example.com$ [NC]
>> RewriteRule ^(.*)        http://example.com/$1 [L,R=301]
>
> Kim, I don't think this will work for requests other than the default
> page. An alternative might be :
>
> RedirectMatch permanent ^www.(.*) http://$1

Or leave the $ anchor off the end of the RewriteCond regex ... I suppose
it is there for a reason but I can't think of it atm.

Posted by Steven Saunderson on August 11, 2006, 7:58 am
Please log in for more thread options


On Fri, 11 Aug 2006 12:36:01 +0100, Richard Gration

> >> RewriteEngine On
> >> RewriteCond %        !^example.com$ [NC]
> >> RewriteRule ^(.*)        http://example.com/$1 [L,R=301]
> >
> > Kim, I don't think this will work for requests other than the default
> > page. An alternative might be :
> >
> > RedirectMatch permanent ^www.(.*) http://$1
>
> Or leave the $ anchor off the end of the RewriteCond regex ... I suppose
> it is there for a reason but I can't think of it atm.

Good point. My suggestion won't work because RedirectMatch doesn't see
the domain name. Kim is right and I am wrong. Oops.

--
Steven

Similar ThreadsPosted
removing linked image borders in IE5/Mac? July 26, 2004, 3:07 am
removing address,tool menu bars December 9, 2007, 9:33 am
little icon on location bar: HOW?? August 17, 2004, 10:26 am
How to link to a location within another document? November 13, 2005, 2:10 pm
Location header question December 9, 2005, 11:29 am
Alt cgi-bin location for virtualhost domain August 4, 2008, 6:37 pm
question on location obtained by website - How ? June 12, 2005, 2:46 pm
URI scheme for (geographical) map or address location? To-Do? March 9, 2007, 12:41 pm
Frames that haven't loaded and document location January 30, 2008, 11:53 am
Free Location-Aware Message for Web Sites November 23, 2004, 5:41 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap