nginx位置块匹配订单查询
我的conf文件中有以下内容:nginx位置块匹配订单查询,nginx,Nginx,我的conf文件中有以下内容: server { listen 80; server_name a.mydomain.com; location /f/ { alias /var/www/sites/mydomain/photos/; expires 1y; } location ~ \.(php|html)$ { include php.conf; } location / {
server {
listen 80;
server_name a.mydomain.com;
location /f/ {
alias /var/www/sites/mydomain/photos/;
expires 1y;
}
location ~ \.(php|html)$ {
include php.conf;
}
location / {
return 301 http://www.mydomain.com$request_uri;
}
}
php.conf在哪里
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "include_path=.:/usr/share/pear:/var/www/sites/mydomain/conf";
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
让我困惑的是,我的最终位置(“location/”)块完全符合我的要求。除以/f/get开头的请求以外的任何请求都会重定向到父www域
太好了,这正是我想要的。
但是,文档中另有说明。它说我拥有的regexphp块应该在最后的“/”块之前匹配(并且优先)
不是吗
“位置指令的检查顺序如下:
- 具有与查询完全匹配的=前缀的指令(文字字符串)。如果找到,搜索将停止
- 具有常规字符串的所有剩余指令。如果此匹配使用了^~前缀,则停止搜索
- 正则表达式,按照它们在配置文件中定义的顺序
- 如果#3产生匹配,则使用该结果。否则,将使用#2中的匹配。”
a.mydomain.com/myfile.php
?是的,这最终会出现在www.mydomain.com/myfile.phpLooks上,就像你是对的(但我没有确认)。这就是你想要的!:)要了解它真正在做什么,您可以查看源代码!不过,我不确定这是否值得。