Reputation: 7589
I am having a problem with modrewrite using the below rule. I am getting an 404 error because the rule doesn't seem to work. can someone provide a solution on how to get it working?
RewriteRule ^/catalogue/([^/\.]+)/results.html$ /search.php?data=$1 [L]
it should process urls like the following but gives me a 404:
http://www.mydomain.com/catalogue/europe/germany/results.html
thanks in advance.
Upvotes: 0
Views: 54
Reputation: 2277
Try this rule:
RewriteRule ^/catalogue/(.+?)/results.html$ /search.php?data=$1 [l]
Your rule isn't working because of your capturing pattern:
[^/\.]+
basically means:
Match anything that is not a / or a . for as many times as possible.
But it will stop at the first next / in the url, which causes it not to match anything
Upvotes: 1
Reputation: 91734
You example url is not affected by your rewrite rule; using [^/\.]+
you are allowing all characters except the forward slash and the dot, so europe/germany
does not match because it has a forward slash.
I don´t know what you want to allow exactly, but for your example url you could use something like:
RewriteRule ^/catalogue/([a-zA-Z/]+)/results.html$ /search.php?data=$1 [L]
which would allow a
to z
(upper and lower case) and the forward slash.
Upvotes: 1
Reputation: 21553
RewriteRule ^catalogue/(.+?)/results.html$ /search.php?data=$1 [L]
Upvotes: 1