Hello,
how do I best handle multiple locations that use the same code block? I do not want to repeat the { … } part. Is there a way to do this with logical or between regular expressions?
The first variation is that sometimes there are query parameters, and sometimes there are not. The second variation is that there are multiple suffixes that should match the same block.
As an example, the following locations all should have the same behaviour:
* /variable-part.gif
* /variable-part.gif?variable-query-parameters
* /variable-part.png
* /variable-part.png?variable-query-parameters
The equivalent regular expressions I am using are:
* ~* \.gif$
* ~* \.gif\?
* ~* \.png$
* ~* \.png\?
I know, I can combine the different types:
* ~* \.(gif|png)$
* ~* \.(gif|png)\?
But I don’t know how to combine the end-of-uri with the followed-by-query-parameters into a single regex.
Lastly, I also have locations with a quite different pattern that has the same code block.
So, what I would like is something like this:
location ( ~* \.(gif|png)$ | ~* \.(gif|png)\? | = /xyz ) { … }
“|” represents a logical or.
Is there a way to do this?
BTW, should the regular expression be in quotes (single or double)?
Thanks…
Roger
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx