
Originally Posted by
celticwebsolutions
Is there any advantage to using the one you have posted up?
There's three advantages:
Your code generates a 302 redirect. That is not what you want. My code sends a 301 redirect.
Your code uses the (.*) pattern which is "greedy and ambiguous". It matches "anything, everything or nothing". It likely requires hundreds of "back off and retry" attempts to find the correct match. My code can be parsed in a single left-to-right read operation. My code will parse a lot faster.
Your code doesn't specify the target domain name, and therefore can lead to an unwanted multi-step redirection chain when URLs on the non-canonical domain are requested.
The new code avoids all of those problems:
Code:
RewriteRule ^shop/(([^/]+/)*)([^/.]+)\.html$ http://www.example.com/$1$3 [R=301,L]