How To Redirect Permalink Using .htaccess
Yesterday i was confused to find a way to change my Manchester United Blog permalinks. When i started the blog about a year ago, i didn’t realize how important it was to have a pretty permalink for SEO purposes.
However, yesterday i decided to change the permalink into more search engine friendly but also don’t want to lose any of those backlinks.
The objective was to change this structure:
My effort started by doing Google search and leads to this post by SearchEngineJournal but the new permalinks didn’t work, as backlinks always lead to 404 pages. I’m not sure why. I think it work for most people since i didn’t see anyone complaining at the post comments except me :D, sorry, i’m not that techie i suppose.
Anyhow i tried to do the search deeper to find a way to solve this problem and leads to Joost De Valk’s Permalink Redirect plugin. I installed the plugin and it still didn’t work. Then this moment came. I finally had the courage to email him asking why the plugin didn’t work. Well, it will be a long back and forth email to answer my question since the reason must be somewhere at the process. However he replied to my email asked me to try using .htaccess and give me these codes:
RedirectMatch 301 /\d\d\d\d/\d\d/\d\d/(.*) /$1
So i created a .htaccess, using it in my blog and it suddenly work! Just worked.
Anyway, if you don’t know how to create the .htaccess file (and don’t have any in your blog folder), here’s how.
- Copy above code into a text editor.
- Name the file as ‘.htaccess’ (no quotes) then save.
- Now open your File Explorer or FTP Explorer. You’ll find .htaccess.txt. Click on the file and push F2 or click twice (not double click) to rename the file. Delete the .txt file so the file should look like this: .htaccess (no file extension).
- Now simply FTP the .htaccess file to your blog root.
- That would be it.
- Please note that this work with the link structure started as /year-month-day-post-title and change it to /post-title. Other way i’m not sure this technique will work.
Joost de Valk is a very cool guy and i will never forget this. I know he must be very busy but he still take time answering emails and answer my questions. If you never heard of him (i doubt you never heard of him if you’ve been around the blogosphere for a while…) here’s his very cool blog. You can find many useful SEO/Blogging/Wordpress related posts, especially his WordPress SEO article. A must read to every WordPress website owners.