How to access query parameter names with '-' in it

Jonathan Kolb kolbyjack at gmail.com
Thu Nov 13 14:38:17 UTC 2014


You can also accomplish this without matching in a map:

map $pipe $dashed_param {
  default $arg_param-name;
}

(I tried a geo block first, but it expanded to a literal '$arg_param-name'
for some reason)

On Wed, Nov 12, 2014 at 5:43 PM, Francis Daly <francis at daoine.org> wrote:

> On Wed, Nov 12, 2014 at 03:38:03AM -0500, sudarshan wrote:
>
> Hi there,
>
> > If query parameters in the request looks like this
> >
> > /something.cgi?param_name=1&param-name=2
> >
> > I can access 'param_name' as $arg_param_name. How do I access
> 'param-name'
> > though? $arg_param-name will not work since as far as nginx is concerned
> the
> > variable name ends at $arg_param. Is there a workaround for this case?
> Has
> > anyone else run into a similar problem?
>
> If you want to avoid embedded languages, you could match-and-extract
> from $args, either with a map or an if, to set your variable name to
> the matching value in "&?param-name=([^&]*)".
>
> But it might be less work to change the input to restrict itself to
> nginx-friendly characters.
>
>         f
> --
> Francis Daly        francis at daoine.org
>
> _______________________________________________
> 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/20141113/105dd7f9/attachment.html>


More information about the nginx mailing list