WordPress – mod_rewrite replace character

mod-rewriteWordpress

I know this should be the easiest thing in the world, but I just can't get my head around rewriting and I have to do it so infrequently that I end up trawling Google for hours….

I'm consolidating two wordpress blogs into one new blog at a different URL. Alas, they both have different permalink structures.

The best thing I can come up with, is to redirect the less popular of the two to the search function of the new one – however I've fallen at the last hurdle: I need to replace all instances of hyphens in the URL to plus symbols.

What I have is this:

RedirectMatch permanent /[0-9]{4}/[0-9]{2}/([a-z0-9\-]+) http://www.mynewblogurl.com/blog/?s=$1

Which will give me:
http://www.mynewblogurl.com/blog/?s=the-title-of-the-blog

I just need to find a way of changing those hyphens into plus symbols.

Best Answer

You're trying to do a search/replace using regex in rewrite rules, which isn't possible. You can see some potential workarounds in this previous question