rewrite with $request_uri auto appends args

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


> Classic "redirect everything" example contains
> '?'.  See e.g. here:
> 
> http://nginx.org/en/docs/http/converting_rewrite_rules.html
> 
> : server {
> :     listen       80;
> :     server_name  nginx.org;
> :     rewrite   ^ http://www.nginx.org$request_uri?;
> : }

Well, it sure does.  http://wiki.nginx.org/Pitfalls#Taxing_Rewrites 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
statement.

Thanks!

-- 
Ron

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,148047,148067#msg-148067




More information about the nginx mailing list