When using named capture, if PCRE library is old, Nginx config won’t support lines like below:
~^(?<blogpath>/[_0-9a-zA-Z-]+/)files/(.*)
Rather than getting $blogpath in named capture, you will get error like:
nginx: [emerg] pcre_compile() failed: unrecognized character after (?< in "^(?/[_0-9a-zA-Z-]+/)files/(.*)” at “blogpath>/[_0-9a-zA-Z-]+/)files/(.*)” in /etc/nginx/conf.d/my.conf:2
Solution
Replace ?
with ?P
So above line should be rewritten as:
~^(?P<blogpath>/[_0-9a-zA-Z-]+/)files/(.*)
You can notice there is a P
between ?
and <