moeffju.net

Getting rid of the 'www' prefix

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

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.

Comments

  1. [no-www-prefix-remove-rewrite#comment586]

    didnt the mutant always do that?

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

    by fengor on Jul 9, 2006 @ 04:49pm

  2. [no-www-prefix-remove-rewrite#comment587]

    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.

    by sankatze on Jul 9, 2006 @ 06:29pm

  3. [no-www-prefix-remove-rewrite#comment588]

    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.)

    by moeffju on Jul 10, 2006 @ 12:11am

  4. [no-www-prefix-remove-rewrite#comment589]

    Hi Matt, long time no see :) How are you??

    Well… I never liked the www… it’s annoying.

    by Juliana on Aug 27, 2006 @ 08:48pm

  5. [no-www-prefix-remove-rewrite#comment590]

    We could not get this to work in the apache configuration file but it seems to work just fine in an .htaccess file.

    by Joseph Crawford on Mar 31, 2007 @ 01:23am

  6. [no-www-prefix-remove-rewrite#comment591]

    The no-www movement…

    Starting today I am no longer going to use the www. on my domain name. There are a few reasons I have come to this conclusion. In my opinion my domain is josephcrawford.com the www. is just a sub-domain of my domain. The www. in a domain name was ju…

    by Joseph Crawford on Mar 31, 2007 @ 03:50am

  7. [no-www-prefix-remove-rewrite#comment592]

    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.

    by Joseph Crawford on Apr 10, 2007 @ 01:00am