Not matching ? as literal
Posted: Wed Nov 19, 2008 8:24 am
Hi,
I'm pretty new to regex and still trying to figure out how to do simple things.
Can anyone explain to me why this redirect works in my .htaccess file (I'm on Apache):
When I use the url:
http://www.mydomain.com/blah.htmlRD=123
this redirect works properly:
RewriteRule ^([^/]+)\.htmlRD\=123$ test22.php?q=$1 [L]
BUT when I use the url
http://www.mydomain.com/blah.html?RD=123
This redirect gives me a 404 error blah.html not found:
RewriteRule ^([^/]+)\.html\?RD\=123$ test22.php?q=$1 [L]
The only difference between the two is that I added ? before RD. I thought I can use a question mark as a literal if I escape it with \ so I don't understand why the second example doesn't work.
Thanks.
I'm pretty new to regex and still trying to figure out how to do simple things.
Can anyone explain to me why this redirect works in my .htaccess file (I'm on Apache):
When I use the url:
http://www.mydomain.com/blah.htmlRD=123
this redirect works properly:
RewriteRule ^([^/]+)\.htmlRD\=123$ test22.php?q=$1 [L]
BUT when I use the url
http://www.mydomain.com/blah.html?RD=123
This redirect gives me a 404 error blah.html not found:
RewriteRule ^([^/]+)\.html\?RD\=123$ test22.php?q=$1 [L]
The only difference between the two is that I added ? before RD. I thought I can use a question mark as a literal if I escape it with \ so I don't understand why the second example doesn't work.
Thanks.