Forum Moderators: phranque

Message Too Old, No Replies

match query string doesn't work

         

roquesao

2:08 pm on Dec 30, 2014 (gmt 0)

10+ Year Member



Hi I want to match a query string with modrewrite , the problem is that my query_string has a url as value:

%{QUERY_STRING} next=https://play.google.com/store/apps/details?pepe=1

and it doesn't work for me.

input='next=https://play.google.com/store/apps/details?pepe=1'
patttern='next=https://play.google.com/store/apps/details?pepe=1' => not-matched

but if I had to match only the uri , it works , the problem is when I try to add parameters to the query_string url:

http://example.com?next=https://play.google.com/store/apps/details?pepe=1


is there any way to match that kind of query_string?

thanks in advance.

[edited by: Ocean10000 at 3:44 pm (utc) on Dec 30, 2014]
[edit reason] examplified [/edit]

phranque

7:00 pm on Dec 30, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, roquesao!


Please show your exemplified mod_rewrite directives.

lucy24

7:47 pm on Dec 30, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you mean that the literal question mark is part of the query string? At a minimum you'd have to escape it (within your RewriteCond) as \? But it's also possible it has been escaped in transit to %3F so put that in the RewriteCond instead.

:: detour to test site for experimentation ::

For me it works if I simply escape the question mark as \? so see if this works:

RewriteCond %{QUERY_STRING} \?
RewriteRule ^. http://www.example.com/question? [R=301,L]


If you end up on your 404 page with URL saying example.com/question then you're good to go. Otherwise try replacing the question mark with %3F.