There are some cases that you want to change the permalink of your wordpress. Maybe for SEO reasons or whatever. In my case, I changed it from the custom permalink “%postname%-%year%%monthnum%%day%” to the usual “%postname%” permalink structure since the latter structure is much “TIME” friendly compare to my old structure. Time friendly because, the old permalink changes the post link whenever I change the publish date of the post which makes the old post with old date a 404 page due to the said changes. It was fine back then since I am not frequently changing the post date of my post so it does not matter back then but this time its different. So I decided to change this structure.

Back then before the new versions of WordPress, I tried to use Advanced Permalink plugin to this stuff but it the plugin is not working anymore. I’ve tried it for several times and it does not redirect the old permalink to the new one. So what I did is use redirect all the post to the new permalink structure using the .HTACCESS redirection.

The following is the redirection I added in .HTACCESS:

RedirectMatch 301 /(.*)-([0-9]+)/$ http://www.bleuken.com/$1

This code, redirects post like “http://www.bleuken.com/manny-pacquiao-vs-floyd-mayweather-20150303/” to “http://www.bleuken.com/manny-pacquiao-vs-floyd-mayweather/”

For structure like this: “http://www.bleuken.com/2015/03/manny-pacquiao-vs-floyd-mayweather/” pointing to “http://www.bleuken.com/manny-pacquiao-vs-floyd-mayweather/”, you can try the following instead:

RedirectMatch 301 /([0-9]+)/([0-9]+)/(.*)/$ http://www.bleuken.com/$3

For NGINX users, you can try the following code instead for this purpose.

# nginx configuration
location ~ /(.*)-([0-9]+)/$ {
rewrite ^(.*)$ http://www.bleuken.com/$1 redirect;
}

Now to make sure this works, save again your new permalink structure to flush the new changes.

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments