Changing My WordPress Blog URL and Using Lighttpd to Redirect

My blog’s old domain, law-family.org and bradford.law-family.org, are set to expire in November. The reason I initially registered the law-family.org domain was to create a family website. My familylighttpd_logo 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, that’s why it’s now theblawblog.com. 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)\.(law-family\.org)$” {
$HTTP["host"] =~ “^(.+\.)?(law-family\.org)$” {
url.redirect = (
“(.*)” => “
http://theblawblog.com”)
url.redirect-code = 301
}
}
$HTTP["host"] =~ “bradford.law-family.org” {
url.redirect = (
“^/(.*)$” => “
http://theblawblog.com/$1″ )
url.redirect-code = 301
}

The first group handles any request to a subdomain of law-family.org EXCEPT bradford.law-family.org and redirects them to http://theblawblog.com with a redirect code of 301.

The second group handles any request to bradford.law-family.org and redirects them to http://theblawblog.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:

This entry was posted in Linux, Project and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>