Tag Archives: domain

Getting Rid of www

[fr]

Une recette pour faire disparaître magiquement ce satané "www" des noms de domaines que j'héberge...

[en]

I personally hate having “www” in front of a domain name. It’s redundant. If we’re visiting a website, we’re on the web anyway. It also brings no end of problems when people start writing for the web and creating links, because they think that what makes something a “website address” is the “www” in front if it, instead of “http://”. That’s how they end up with links like “http://example.com/www.yahoo.com” on their sites. But I digress.

On one of the sites I manage, we have a restricted members-only area. However, our users started reporting that when they used “www” in front of the domain name, they were being asked for the password twice. I tried myself, and I was simply asked for the password ad aeternam. Probably a server configuration glitch somewhere.

Anyway, I decided the simplest solution was to redirect all “www” requests to the non-www domain. I know I had that in place for CTTS at some point, but the setting must have got lost at some point. Instead of sticking rewrite rules in .htaccess as no-www.org suggests, I modified my vhost configuration slightly so that it looked like this:

<virtualHost *:80>
ServerName example.com
DocumentRoot /home/example/www/
ErrorLog logs/example-error
CustomLog logs/example-access combined
</virtualHost>

<virtualHost *:80>
ServerName www.example.com
Redirect permanent / http://example.com/
</virtualHost>

Try it!

http://www.cafecafe.ch/

Many thanks to those who gave suggestions and nudged me along the way to this solution.

Similar Posts:

Tagged apache, domain, htaccess, name, no-www, Real Live Code, vhost, web, website, www | Leave a comment