adding query string to redirect ?

António P. P. Almeida appa at perusio.net
Mon Jul 1 21:53:46 UTC 2013


At the location/server level try:

if ($is_args) {
    return 301 https://$host$request_uri&source=server1;
}

## Goes here if the above is not chosen.
return 301 https://$host$uri?source=server1 ;



----appa



On Mon, Jul 1, 2013 at 11:18 PM, Jonathan Vanasco <nginx at 2xlp.com> wrote:

>
> we'd like to add onto the query string an identifier of the nginx server
>
> something like:
>
> return 301 https://$host$request_uri?source=server1 ;
>
> the problem is that we can't figure out how to make this work correctly
> when the url already contains query strings.
>
>
> Example:
> return 301 https://$host$request_uri?source=server1 ;
> Good!
>  in  /foo.bar
>  out /foo.bar?source=server1
> Bad!
>  in  /foo.bar?a=1
>  out /foo.bar?a=1?source=server1
>
> How can we get this?
>
>  in  /foo.bar
>  out /foo.bar?source=server1
>
>  in   /foo.bar?a=1
>  out /foo.bar?a=1&source=server1
>
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130701/0aa8d1b6/attachment.html>


More information about the nginx mailing list