[Cialug] nginx redirect with '?' in uri

Jeffrey Ollie jeff at ocjtech.us
Mon Sep 10 22:02:16 UTC 2018


Your problem is that nginx won't even try to match parts of the query
string against location blocks:

https://serverfault.com/questions/811912/can-nginx-location-blocks-match-a-url-query-string

On Mon, Sep 10, 2018 at 4:46 PM, Nicolai <nicolai-cialug at chocolatine.org>
wrote:

> Hey all,
>
> This is probably super simple: I just want to redirect a single URI, in
> nginx, that includes a '?' character.
>
> This works:
>
> location = /blah.php {
>         return 302 https://www.example.com;
> }
>
> This doesn't work, resulting in a 404 instead of a temp. redirect:
>
> location = /blah.php?s=47 {
>         return 302 https://www.example.com;
> }
>
> I assume the question mark character is being interpreted as a regular
> expression.  I tried escaping it with a '\' character, which didn't
> work, and also tried enclosing the whole URI in quotes, which didn't
> work either.  Plus some other more dubious things.  What's the solution?
>
> Nicolai
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>



-- 
Jeff Ollie
The majestik møøse is one of the mäni interesting furry animals in Sweden.


More information about the Cialug mailing list