Nginx 没有 removehandler 指令。您将位置块添加到服务器不同类型的请求。
我假设上传文件夹可能有 .php .phtml .php3 .php5 文件,当从该文件夹请求时,您不想执行它们。这是我的建议:
location ^~ /uploads/ {
root /var/www/unkown-user-data;
expires max;
}
注意:“^~”很重要(意味着比正则表达式“~”块具有更高的优先级)。否则,正则表达式位置块,例如
location ~ \.php$ {
...
}
会先匹配,会错误执行php脚本。这是 nginx wiki 中的匹配顺序:
1. Directives with the "=" prefix that match the query exactly (literal string). If found, searching stops.
2. All remaining directives with conventional strings. If this match used the "^~" prefix, searching stops.
3. Regular expressions, in the order they are defined in the configuration file.
4. If #3 yielded a match, that result is used. Otherwise, the match from #2 is used.