why should I use question mark ?

Maxim Dounin mdounin at mdounin.ru
Fri Jul 6 16:23:02 UTC 2012


On Fri, Jul 06, 2012 at 10:44:15PM +0800, 任晓磊 wrote:

> I want rewrite a uri to itself without querystring, I tried
> rewrite .+ $uri permanent;
> but it rewrite to the original uri, with querystring unstripped.
> After googled, I try
> rewrite .+ $uri? permanent;
> and it works correctly. 
> But why?

Because it's how it's expected to work.  By default the "rewrite" 
directive preserves query string, and even if you write arguments 
in a replacement string - they are added before original query 
string which is still preserved.  Trailing question mark is an 
explicit flag that you don't want to preserve query string.


Maxim Dounin

More information about the nginx mailing list