Redirect 301 or RedirectRule?

hi gurus,

I’m trying to redirect pages from

www.domain.com/category/product-name/reviews

to

www.domain.com/category/product-name/reviews/1

How can I achive this? It looks easy at first sight and I had tried

Redirect 301 /category/product-name/reviews /category/product-name/reviews/1

but page still doesn’t redirect

btw, what tools can I use to test htaccess rules?

Came back with another similar situation and need some advice here.

say i had a url /post-title-here/ which needs to be redirected to /blog/post-title-here and was achieved using:

Redirect 301 /post-title-here/ /blog/post-title-here/

Now that’s all fine until coincidentally, there’s a valid url such as

/post-title-here/reviews

that will fail to load the right page because of that Redirect

So I then change the rule to Redirect 301 /post-title-here/$ /blog/post-title-here which will make /post-title-here/reviews load correctly.

But then, /post-title-here/ doesn’t get redirected to /blog/post-title-here/ anymore. Can someone show me some light?

Thanks.

thanks David, brilliant solution!

tth,

While mod_alias is faster than mod_rewrite (because it’s part of Apache’s core), it lacks the power of mod_rewrite which is designed to use Apache’s regex engine. Yes, RedirectMatch uses regex but it can’t use conditionals.

I’d either:

  1. Rename that directory with the reviews link

OR

  1. Learn mod_rewrite to control the redirection (and provide an exclusion to the {whatever}/reviews URI).

Regards,

DK

tth,

IMHO, your redirect is not sufficiently different to not loop. Okay, at least that’s what I suspect is your problem.

Using mod_rewrite, you could add the /1 using:

RewriteEngine on
RewriteRule category/product-name/reviews$ category/product-name/reviews/1 [R=301,L]

The key to this NOT looping is the “end anchor,” the $ after reviews in the regex. Since your redirection cannot be served by Apache, place this before your CMS’s mod_rewrite block.

Regards,

DK