[Cialug] nginx redirect with '?' in uri

Nicolai nicolai-cialug at chocolatine.org
Mon Sep 10 21:46:46 UTC 2018


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


More information about the Cialug mailing list