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.
Not matching ? as literal
Moderator: General Moderators
Re: Not matching ? as literal
This is not a regex problem actually. The thing is that RewriteRule does never match the query string.
Note: Query String
The Pattern will not be matched against the query string. Instead, you must use a RewriteCond with the %{QUERY_STRING} variable.
http://httpd.apache.org/docs/2.0/mod/mo ... ewriterule
Re: Not matching ? as literal
Bingo!
Thank you so much!
--Susie
Thank you so much!
--Susie