Answer the question
In order to leave comments, you need to log in
nginx regexp question
Please help.
Problem:
When requesting the file http: //serv/*.pgp, the contents of key.pgp were returned,
but not when requesting http: //serv/something/*.pgp
(instead of * - any set of [a-zA-Z0-9\ .] (alphanumeric and period)
location ~* /[a-zA-Z0-9\.]+\.(pgp|gpg|key)$ {
root /www/http/_global;
rewrite $ /key.pgp break;
}
location = /key.pgp {
root /www/http/_global;
}
second condition doesn't work (request http: //serv/something/key.php returns a file)
Answer the question
In order to leave comments, you need to log in
First, /[a-zA-Z0-9\.]+\.(pgp|gpg|key)$ will match any URI ending in /*.pgp (including /something/*.pgp), you they themselves did not bind the regular season to the beginning of the "^".
Secondly, do you really need a rewrite right now?
location ~* ^/[a-z0-9\.]+\.(pgp|gpg|key)$ { try_files /www/http/_global/key.pgp =404; }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question