Reputation: 1244
The following htaccess based redirection rule works fine:
Redirect 301 /content/category/2/24/30/ /new/c/url/
The problem is it works too well. If a user goes to
/content/category/2/24/30/50/50/
it will redirect to:
/new/c/url/50/50/
How can I get it to do a strict match? Either redirecting both examples to simply:
/new/c/url/
would be fine, otherwise ignoring the longer version is good too.
Thanks!
Upvotes: 0
Views: 637
Reputation: 7220
And the solution should be
RedirectMatch 301 ^/content/category/2/24/30/$ /new/c/url/
Basically you're saying the 30/ is the end of the string.
I can't try it so let me know if it's not working.
^ matches the beginning of a string and $ matches the end of a string.
Read this if you want to know more about it: http://www.regular-expressions.info/
Upvotes: 0
Reputation: 655489
Redirect
matches path prefixes and not just the whole path. If the given path prefix matches the requested path, the remaining path from the prefix on is appended to the replacement path.
So use RedirectMatch
instead with ^
and $
marking the start and end of the path:
RedirectMatch 301 ^/content/category/2/24/30/$ /new/c/url/
Upvotes: 3