regex problem with helicon ape on windows server 2008
-
08-10-2019 - |
Question
I have the following rewrite rules:
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\\.php\?(.*) /$2.php?shop=$1&$3 [NC,L]
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\\.php /$2.php?shop=$1 [NC,L]
RewriteRule ^([a-zA-Z0-9]*)/$ /index.php?shop=$1 [L,NC]
RewriteRule ^([a-zA-Z0-9]*)$ /index.php?shop=$1 [L,NC]
The result of which should redirect the following:
www.site.com/Sells
-> /index.php?shop=Sells [works]
www.site.com/Sells/menu.php?Cat=1
-> /menu.php?shop=Sells&Cat=1 [failing]
-> /menu.php?shop=Sells [which is 'wrong']
The last example should get matched by rewrite [1]...
I have tested the rules with the regex tester shipped with ape and found that escaping ?
and .
don't seem to work. I am a little flummoxed and would appreciate anyone who
could shed some light on why this escaping is not working.
Loads of thanks in advance.
Solution 3
QSA flag was missing! it appends the query string and I forgot to put it in!!!
The double slashes I added as preview was not showing the single ones!
OTHER TIPS
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\\.php\?(.*) /$2.php?shop=$1&$3 [NC,L]
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\\.php /$2.php?shop=$1 [NC,L]
Too much escaping. Change \\.php
to \.php
.
You seem to escape the \ that is meant to escape the . (you have \. which is read as \ and any letter/symbol)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow