<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">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?</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">As an example, the following locations all should have the same behaviour:</div><div class="">* <font face="Courier New" class="">/<i class="">variable-part</i>.gif</font></div><div class="">* <font face="Courier New" class="">/<i class="">variable-part</i>.gif?<i class="">variable-query-parameters</i></font></div><div class="">* <font face="Courier New" class="">/<i class="">variable-part</i>.png</font></div><div class="">* <font face="Courier New" class="">/<i class="">variable-part</i>.png?<i class="">variable-query-parameters</i></font></div><div class=""><br class=""></div><div class="">The equivalent regular expressions I am using are:</div><div class="">* <font face="Courier New" class="">~* \.gif$</font></div><div class="">* <font face="Courier New" class="">~* \.gif\?</font></div><div class="">* <font face="Courier New" class="">~* \.png$</font></div><div class="">* <font face="Courier New" class="">~* \.png\?</font></div><div class=""><br class=""></div><div class="">I know, I can combine the different types:</div><div class="">* <font face="Courier New" class="">~* \.(gif|png)$</font></div><div class="">* <font face="Courier New" class="">~* \.(gif|png)\?</font></div><div class=""><br class=""></div><div class="">But I don’t know how to combine the end-of-uri with the followed-by-query-parameters into a single regex.</div><div class=""><br class=""></div><div class="">Lastly, I also have locations with a quite different pattern that has the same code block.</div><div class=""><br class=""></div><div class="">So, what I would like is something like this:</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">location ( ~* \.(gif|png)$ | ~* \.(gif|png)\? | = /xyz ) { … }</font></div><div class=""><br class=""></div><div class="">“<font face="Courier New" class="">|</font>” represents a logical or.</div><div class=""><br class=""></div><div class="">Is there a way to do this?</div><div class=""><br class=""></div><div class="">BTW, should the regular expression be in quotes (single or double)?</div><div class=""><br class=""></div><div class="">Thanks…</div><div class=""><br class=""></div><div class="">Roger</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>