Redirections in Lighttpd
I prefer my websites have no www suffix, it makes the URLs shorter and simplifies things so all your links appear on the same domain. However, some people like to add the www suffix to everything.
You can easily support this in lighttpd using the url redirect module. NOTE: When I set this up on my server I had to have the base domain configuration above the www subdomain configuration.
$HTTP["host"] == "abc.com"
{
...
}
$HTTP["host"] == "www.abc.com" {
url.redirect = (
"^/(.*)$" => "http://abc.com/$1"
)
}
In the example above, if you request the URL http://www.abc.com/page/1 - you will instead be taken to http://abc.com/page/1
You can also use url redirect to setup permanent 301 redirects from pages that are no longer available or have a new URL. This helps for SEO as there may be many sites that link to a certain page, and if that page is no longer available, Google may not count it towards your page rank.
$HTTP["host"] == "abc.com" {
url.redirect = (
"^/old-page$" => "/new-page"
)
}
Links: