如何在nginx中的sublocation中将所有请求定向到index.php?

时间:2017-02-14 08:28:54

标签: nginx

配置的一部分:

    auth_basic           "closed site";
    auth_basic_user_file /etc/nginx/htpasswd;


    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ^~ /api {
            auth_basic off;
    }

当我请求http://myserver.com/any/url时 - 它会提示输入http密码。没关系。

但是当我请求http://myserver.com/api/anything时,我不想提示密码。

日志错误:

"/var/www/public/api/anything" failed (2: No such file or directory), client: 1.2.3.4

但实际上请求必须转到" /var/www/public/index.php"。为什么它没有命中index.php?

0 个答案:

没有答案
相关问题