rewrite with $request_uri auto appends args

NCRonB nginx-forum at
Fri Nov 5 20:49:35 MSK 2010

> Classic "redirect everything" example contains
> '?'.  See e.g. here:
> : server {
> :     listen       80;
> :     server_name;
> :     rewrite   ^$request_uri?;
> : }

Well, it sure does. does
not show the '?' and I (think) I've read many other configurations that
don't have it, but perhaps I'm just getting old.

> rewrite is expected to preserve original args in
> all cases (either 
> preserve as is, or append if you added other
> arguments) unless you 
> specified trailing '?'.

Got it.  However, if you use $request_uri, doesn't that always preserve
the original args by itself?  I'm having trouble thinking of an example
where you would NOT want a question mark after $request_uri in a rewrite



Posted at Nginx Forum:,148047,148067#msg-148067

More information about the nginx mailing list