Why doesn't this RedirectMatch work?

New to mod_rewrite? This is a good place to start.

Why doesn't this RedirectMatch work?

Postby wwday3 » Wed Sep 05, 2007 10:17 pm

I've been experimenting a bit with RedirectMatch. I've successfully redirected a number of Blogger blog posts to their equivalent Wordpress posts. (And, I successfully used the "archive" pattern mentioned in another post). But, the following doesn't seem to work, and I'm not sure why:

RedirectMatch 301 ^/search/label/(.+) http://domain.com/category/$1/

I also tried these variations

RedirectMatch 301 ^/search/label/(.+)$ http://domain.com/category/$1/
RedirectMatch 301 ^/search/label/(.*) http://domain.com/category/$1/

It's like the incoming URL string never terminates. When I type in the search/label/whatever followed by a single '/', it works (but I get a double '//' in the resolved URL). If I don't add the '/', I get a 404 error.

Help, please?
wwday3
 
Posts: 15
Joined: Wed Aug 29, 2007 10:18 pm

Postby richardk » Thu Sep 06, 2007 3:00 pm

.+ and .* match everything, including any trailing slashes. Try
Code: Select all
RedirectMatch 301 ^/search/label/(.*[^/])/?$ http://domain.com/category/$1/
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 49 guests

cron