【发布时间】:2016-09-30 17:07:16
【问题描述】:
我有一个 NGINX 服务器,我使用 Apache 实用程序的密码要求 (.htpasswd)。它大部分工作正常。以下这项工作正常:
example.com/admin
example.com/admin/
example.com/admin/index
但是...
当我输入example.com/admin/index.php 并且根本不输入任何密码并按“中止”时,服务器显示的是 index.php(没有任何 CSS 或 JS 文件)。我认为我的 PHP-FPM 是问题所在。请看:
location / {
try_files $uri $uri.html $uri/ @extensionless-php;
index index.html index.htm index.php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
location /admin {
auth_basic "Restricted";
auth_basic_user_file /admin/.htpasswd;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$
}
【问题讨论】:
-
参见this,但基本上您的身份验证适用于
location /admin,.php文件由location ~ \.php$处理。 -
我明白了。但是我该如何解决呢?我不知道。
标签: .htaccess nginx .htpasswd apache-utils