<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Although you've used a wrong list for your question (this is development mailing list not a forum for howto's),<br />but because I've ATM a free minute, here you go:</p>
<pre>You CANNOT use variables in nginx <span style="font-family: courier new,courier;"><a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#location">location</a></span> uri-pattern (no matter regexp or static URI), </pre>
<pre> </pre>
<pre>so the following code:</pre>
<pre>```<br /> <span style="font-family: courier new,courier;">location ~ ^.../$reg_exp/...$ {...</span></pre>
<pre>```</pre>
<pre>does not substitute the variable (the char $ - is just a dollar character here).</pre>
<pre> </pre>
<pre>The same is valid for directive <span style="font-family: courier new,courier;"><a href="http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#if">if</a></span>, so `<span style="font-family: courier new,courier;">if ($uri ~* ".../$reg_exp/...") { ...</span>` does not interpolate `<span style="font-family: courier new,courier;">$reg_exp</span>`</pre>
<pre>as variable.<br /><br />So what you are trying is impossible in nginx.</pre>
<p>Just write it direct in location-regex (without variable) or use some macros resp. some custom module, <br />that could do it.</p>
<pre><br />In addition please note <a href="http://nginx.org/en/docs/faq/variables_in_config.html">this.</a><br /><br />Regards,<br />sebres.</pre>
<p> </p>
<p>Am 24.01.2018 14:22, schrieb fx.juhel@free.fr:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<pre>Hello nginx DEV TEAM ! How are you ?
I would like to know how can I do to detect this type of directory name with regexp : (Guid 8-4-4-4-12) => "be93d4d0-b25b-de94-fcbb-463e6c0fe9cc"
How can I use $reg_exp in location
I do this :
set $reg_exp "[0-9a-fA-F]{8}?-[0-9a-fA-F]{4}?-[0-9a-fA-F]{4}?-[0-9a-fA-F]{4}?-[0-9a-fA-F]{12}";
location ~ ^/locale/Project/Documents/(reg_exp)/(?<document>.*)$ {
}
Thank you very well for your reply
François – Xavier JUHEL
_______________________________________________
nginx-devel mailing list
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a>
</pre>
</blockquote>
</body></html>