views:

41

answers:

3

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?

+1  A: 

Try something like this:

RewriteEngine On
RewriteRule ^/2009/06/gallery/\(?([^/]*)\/$ /gallery/ [R=301,L]
Prot0
tried, but not work
Edward
it should also works now, thanks anyway
Edward
A: 

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.

Matt Gibson
Hi Matt, Redirection is exactly what i used before i came here. It did a great job on my site for several days and then something went to wrong. When i created a new page in wordpress, nothing else changed, my home page began to be redirected to the new page, despite there is none a rule match my home page.
Edward
That happened to me too, Edward. It's easy to fix though: http://urbangiraffe.com/tracker/issues/show/874
Dennis Pedrie
@Dennis Thanks! Never tripped over this problem myself. I guess the short answer for the problem is "update to the latest Redirection plugin, then delete any redirect for "/" that crept in".
Matt Gibson
+1  A: 
RewriteRule ^[0-9]{4}/[0-9]{2}/gallery/.*$ gallery [R=permanent,L]

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.

Brad F Jacobs
you have a typo in it, it is [R=permanent,L]
Alex
Appeared so, thanks.
Brad F Jacobs
tried too, but not work
Edward
Then you are leaving out some information or your server is mis-configured.
Brad F Jacobs
it works now, when i thought the second one is also needed to be redirected by wordpress so that put it to above wordpress's rules
Edward