John Siu Blog

Tech - Business Tool, Personal Toys

Lighttpd Redirect and WordPress Permalink

☰ Table of Content

I used to use the Date and Name permalink structure for my blog.

1
https://johnsiu.com/index.php/2016/10/13/sample-post/

But I think it is kind of long and want to shorten it, and change it to Post name structure:

1
https://johnsiu.com/index.php/sample-post/

Changing that is as easy as a few clicks in WordPress setting. All existing and future posts will have the new Post name structure.

Issue

However, after I uploaded the new sitemap to Google Webmaster Tool, and start checking my site information, especially Links to Your Site under Search Traffic, I noticed a big issue.

After the permalink structure change, all the links out there with the old structure become broken! Not good!

Solution

Solution? Lighttpd Url.redirect

Since Date and Name permalink format is well structured, the redirect rules is easy:

1
url.redirect = ("^/index.php/\d{4}/\d{2}/\d{2}/(.*)$" => "/index.php/$1")

John Siu

Update: 2020-08-16
comments powered by Disqus