nginx的location匹配顺序是怎么样的?
我的nginx的location配置如下:
server {
listen 80;
root /home/vagrant/www/test/public;
index index.html index.htm index.nginx-debian.html index.php;
server_name www.test.cc;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}
现在我的项目可以正常的访问的。我就想问一下,比如我访问一个地址:www.test.cc/callback/test
class CallBackController extends Controller
{
public function test()
{
echo 999;
}
}
他会正常打印999
那么这个地址他会匹配到哪个location?还是两个location都会匹配到?
之前一直以为只是匹配location ~ .php$这个的,我特意把location /这块全部去掉,运行上面地址,直接报404 Not Found
推荐文章: