LighttpdI own johnsiu.com, johnsiu.org, johnsiu.info, johnsiu.net. They all point to this server. That is already setup in dns. But I want all of them, with or with www, redirect to http://johnsiu.com. Lighttpd give you an easy way to do it.

In /etc/lighttpd/lighttpd.conf, I added the following section

$HTTP["scheme"] == "http" {

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

    $HTTP["host"] =~ "^(www\.)?johnsiu\.(net|org|info)$" {
        url.redirect  = (
            "^/(.*)" => "http://johnsiu.com/$1",
        )
    }

    $HTTP["host"] =~ "^162\.208\.11\.21$" {
        url.redirect  = (
            "^/(.*)" => "http://johnsiu.com/$1",
        )
    }

}

You can see .com is seperated from .net, .org, .info redirection. Why?

That is because I only need to redirect http://www.johnsiu.com to http://johnsiu.com.

I don’t need an infinite loop of http://johnsiu.com to http://johnsiu.com redirection.