【问题标题】:why does ^~ not stop processing routing rules in nginx?为什么 ^~ 不停止在 nginx 中处理路由规则?
【发布时间】:2012-08-24 15:07:11
【问题描述】:

所以我有 2 条路线,第一条路线不会停止路线匹配,正如文档所说的那样:

location ^~ /p/ {
    root /www/domain.com/;
    try_files $uri $uri/ /path/index.html;
}

location ^~ /v/ {
    root /www/domain.com/;
    try_files $uri $uri/ /path/index.html;
}

location ^~ / {
    root /www/domain.com/php_www/;
    try_files $uri $uri/ /index.php;

        location ~* \.(?:php|html)$ {   
            try_files $uri =404;
            fastcgi_pass 127.0.0.1:9000;
            include /etc/nginx/fastcgi_params;
        }

        auth_basic "Staging";
        auth_basic_user_file /www/.htpasswd;

}

如果我有这样的网址:

http://domain.com/p/1234567890

它匹配最后一条路线而不是第一条路线。问题浮出水面是因为我们的一个人在应用程序中添加了一个页面:

http://domain.com/privacy

这是由 FIRST 路线拾取的??问题出在哪里。

我遇到的问题是^~。在文档中,它说一旦匹配,它将停止匹配,但是最后一个路由始终是加载的。

有什么想法吗?

【问题讨论】:

  • 我已经对此进行了一段时间的测试。看来问题与 nginx 未检查第一条路线中的最终“/”有关。所以我可以做 ^~ /p 并且它工作正常,但是 /privacy 页面没有加载。但是当匹配的路由是^~/p/时就不行了。跟这个该死的斜线有关!
  • 升级到最新的 nginx,并重新排序了一些指令,现在一切正常。

标签: nginx webserver rewrite


【解决方案1】:

升级到最新的 nginx,并重新排序了一些指令,现在一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-15
    • 1970-01-01
    • 2015-02-06
    相关资源
    最近更新 更多