Why does this RegEx fail?
The goal is to rewrite:
http://example.com/Almost-Anything-Here/381
--> /lv.php?id=381&%{QUERY_STRING}
Note that I am ignoring the text in the URL and just trying to get the number (in this example, 381), which I pass to lv.php
.
Here is the rule:
RewriteRule ^[/]?[A-Za-z0-9\-_(\.)*]+/([0-9]+)$ /lv.php?id=$1&%{QUERY_STRING} [L]
It works if there are 0, 1 or 2 periods but fails (with an HTTP 500) for 3 or more periods. Why?! I tried a few ways of escaping/capturing the period in the regex but no luck.
Example Test URLs:
- works:
http://example.com/Great/381
- works:
http://example.com/Great./381
- works:
http://example.com/Great../381
- fails:
http://example.com/Great.../381
UPDATE Here is the error msg from the server log, clearly a regex problem, still not sure why...
Access denied with code 500. Pattern match "\\\\.\\\\.\\\\./" at REQUEST_URI. [msg "Bogus Path denied"] [hostname "www.example.com"] [uri "/Great.../381"]