bradford bio photo

Twitter LinkedIn Github Stackoverflow

My blog’s old domain are set to expire in November. The reason I initially registered the domain was to create a family website. My family traditionally has communicated by mass email and reply-all conversations and I thought it would help to give them something different. They rarely used it however so I decided to simply focus on my own blog. Since I have several articles that get regular hits from search engines, I worried that my articles wouldn’t be very visible. I decided to try writing up some redirect rules for my old domain in the lighttpd config file so that anyone going to my old blog links would be redirected to their new addresses.

I came up with the following rules:

$HTTP["host"] !~ "^(bradford).(old-website.org)$" {
    $HTTP["host"] =~ "^(.+.)?(old-website.org)$" {
    url.redirect = ("(.*)" => "http://new-website.com")
    url.redirect-code = 301
    }
}

$HTTP["host"] =~ "bradford.old-website.org" {
    url.redirect = (
    "^/(.*)$" => "http://new-website.com/$1" )
    url.redirect-code = 301
}

The first group handles any request to a subdomain of the old website EXCEPT bradford.old-website.org and redirects them to http://new-website.com with a redirect code of 301.

The second group handles any request to bradford.old-website.org and redirects them to http://new-website.com WITH the trailing address. This works wonderfully as long as you don’t change the structure of your permalinks.

Remember to enable mod_redirect under server.modules in your lightty configuration file.

Sources: