.htaccess & wordpress site - How to add 301 redirect rules for no longer valid permalink?

By : Edward
Source: Stackoverflow.com
Question!

I recently did a big update on my wordpress site, thus some old permalink are invlid now.

Seach google for a tutorial on this and found a lot about static html page redirection examples or specific php page which are not what i'm looking for

Both my old and new permalinks are in path format, for example, i need redirect a couple urls of old gallery posts (deleted) which are

/2009/06/gallery/abc/
/2009/06/gallery/cba/
/2009/06/gallery/bbc/
/2009/06/gallery/aab/

to a new page which is

/gallery/

How do i write a correct redirect rule for this?

By : Edward


Answers
Should get you to where you need to be. If you need the actual parameters (IE Date / Month / Title) passed along it is a bit of a change up, but do-able.

EDIT Fixed typo.



Try something like this:

RewriteEngine On
RewriteRule ^/2009/06/gallery/\(?([^/]*)\/$ /gallery/ [R=301,L]
By : Prot0


Personally, I would use the Redirection plugin rather than editing your .htaccess directly -- it's easier, less danger-prone, and will let you log what redirections have been happening. It will also track 404 errors so you can see if you've forgotten to redirect anything.

Then, if you're just redirecting a couple of fixed posts, it's just a matter of adding a simple rule for each redirect, with the old and the new URLs, on the Redirection configuration page. You can also use regular expressions, as with .htaccess, if you want to do anything more complicated.



This video can help you solving your question :)
By: admin