Greg Hewgill (ghewgill) wrote,
Greg Hewgill
ghewgill

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.

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 *>
    ServerName www.example.com
    Redirect permanent / http://example.com/
</VirtualHost>

Then, remove the ServerName www.example.com 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.

Tags: web
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 7 comments