• Archives

  • Categories

Mar 19

How to redirect www to no-www in Lighttpd

This is pretty easy and is more of a personal note. First check that mod_redirect is enabled in lighttpd.conf:

sudo nano /etc/lighttpd/lighttpd.conf

Uncomment the line that write “mod_redirect”.

server.modules = (
  "mod_rewrite",
  "mod_access",
  "mod_alias",
  "mod_accesslog",
  "mod_compress",
  "mod_redirect",
  …

Then add the following at the bottom of your lighttpd.conf:

$HTTP["host"] =~ "^www.(.*)" {
  url.redirect = ( "^/(.*)" => "http://%1/$1" )
}

Finally, give lighttpd a restart and test it out:

sudo /etc/init.d/lighttpd restart

Hope it helps.

After I made the switch to Lighty, I totally forgot to do redirect all my www sites to no-www, this results in all people who visit www.darylli.com to be shown the default site which is what you see here basically.

Possibly related:

  1. How to set up VirtualHost in Ubuntu
  2. How to log slow MySQL queries
  3. Tonight I’ll fix the server
  4. How to set up VirtualHost in XAMPP for Windows

No comments yet. Leave yours here.


WordPress powered and Django inspired.
Love and elephants come after.
RSS: Posts and comments.