Getting rid of the ‘www’ prefix

[lang_de]Dieser Eintrag ist nur auf Englisch verfügbar.[/lang_de]

You may or may not have heard about the no-www movement. All my sites have always been reachable with and without the www prefix, and I personally never use the www prefix if I can avoid it. I won’t get into the details of why it is a bad idea, but consider this: no one calls the web ‘WWW’ anymore, and this ‘abbreviation’ is a lot longer than the expansion (‘double-you double-you double-you’ vs ‘world wide web’). If anything, the prefix should be ‘web’.

Starting today, I’m having all my domains permanently redirect to the non-www version of the hostname.

Here’s a simple mod_rewrite recipe that should work for any domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L,NS]

Put it inside a <Location "/"> block in the appropriate VirtualHost block, or inside a .htaccess in the document root of your site (it doesn’t seem to work in a VirtualHost block in the server config, any ideas why?).

It’s like magic.

7 Replies to “Getting rid of the ‘www’ prefix”

  1. didnt the mutant always do that?

    besides, i never understood why sites dont have it by default

  2. I never type the WWW, anyway, and I’m always slightly annoyed, if sites aren’t reachable without it. Didn’t know there was a whole organized group though.

  3. The mutant was always reachable with and without prefix, but it didn’t redirect.

    (It still doesn’t, only moeffju.net and sibling sites do.)

  4. Pingback: Joseph Crawford
  5. You should remove the image from comments if it is a trackback rather than showing the big ?, maybe show a trackback image or something to visually seperate them.

Comments are closed.