Redirecting with Lighttpd
June 20th, 2006
I just recently changed my site to permanently redirect http://www.atomgiant.com and http://blog.atomgiant.com to just http://atomgiant.com so please make a note of it.
This will make it easier for me to track my site stats, but just as important, it will have a positive impact on search engine rankings.
There are many ways to perform this redirect such as via meta redirects, but I decided to use Lighttpd for two reasons:
- Lighttpd makes this really easy.
- The redirect is instantaneous. With meta redirects there can be a very noticeable delay.
My lighttpd redirect code is as follows:
$HTTP["host"] =~ "^(www.|blog.)" {
url.redirect = (
"^/(.*)" => "http://atomgiant.com/$1",
"" => "http://atomgiant.com/",
"/" => "http://atomgiant.com/"
)
}
Also, don’t forget to include mod_redirect as one of your lighttpd server.modules
References:
The redirect code was adopted from here
Subscribe to the feed!
October 17th, 2008 at 5:53 am
Here is the code to do exactly the opposite, redirecting with non-www to www.
$HTTP[”host”] =~ “^example.com$” {
url.redirect = ( “^/(.*)” => “http://www.example.com/$1″ )
}
Here is a tutorial on www redirection.