Date: 2005-04-20 11:30:00
Tags: web
the accursed www

The common www part of web server addresses has annoyed me for a long time. It's unnecessary, ugly, and annoying to pronounce. There is even a site, no-www, that is dedicated to the effort of eliminating the www wart on web addresses.

[info]dbaker today pointed me to an easy way to eliminate the www using Apache. Instead of using the cumbersome mod_rewrite as suggested on the no-www site, do something like this:

<VirtualHost *>
    Redirect permanent /

Then, remove the ServerName line from the real server configuration section. This assumes that you are using NameVirtualHost, which isn't the default but probably should be.

This configuration quietly redirects any URL with www to the corresponding URL without. This improves the way your URL looks, improves search engine efficiency, and promotes world peace. Well, maybe not that last thing.

I told you to do this a year ago! :)

dbaker's example is poor, though. what you want to be able to do is redirect all hits properly, as in:
<VirtualHost *:80>

RedirectMatch permanent /(.*)$1

That will properly redirect deep links to the non-lame URL instead of just sending everyone to the main page.
That's what I thought the Redirect option would do too, until I tried it. See for example:

And I'm a slacker, so although you mentioned this a year ago, I just got around to it today. :)
Nutty, I had no idea. How unexpected.
Indeed, it's actually documented this way:

"URL-path a (%-decoded) path; any requests for documents beginning with this path will be returned a redirect error to a new (%-encoded) URL beginning with URL."

Good to know. My mod_rewrite is broken right now for some reason, so this was useful. :)
I'll take that as a formal apology. :)
[info]swimathon : Save www
www is useful. In the same way ftp. dns. mail. archie. etc identify the main purpose of an address, so does www. It also prevents people from having to type in a URL instead of just an address as many systems will easily identify something beginning with www. as being a HTTP url to follow and will automagically link them.

At least this doesn't condone abandoning the www. address I guess.
[info]ghewgill : Re: Save www
Gmail recognizes non-www urls such as as clickable. That's good enough for me.
awwwww and no world peace?


brilliant stuff by the way :)
Hmmmm, I tried this on my server, and I get an error with Firefox!
"Redirection limit for this URL exceeded". OMGWTF!?

DocumentRoot /var/www/html/involution
RedirectMatch permanent /(.*)$1

Greg Hewgill <>