【发布时间】:2017-01-22 20:04:41
【问题描述】:
我遇到了一个奇怪的问题。 我在 nginx 服务器上为 wp-admin 启用了密码保护 但是一旦我启用密码保护,wp-admin 网页的 php 解析就会停止。
意思是,输入用户名和密码后,我可以下载php文件源代码,而不是用登录屏幕查看处理后的HTML。
这是我的配置文件 请告诉我我做错了什么?
server {
... server stuff here ..
# Wordpress Rules
location / {
try_files $uri $uri/ /index.php?$args;
}
location ^~ /wp-admin/ {
auth_basic "Restricted Access";
auth_basic_user_file /home/user/domains/.htpasswd;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
# Cache control
location ~* \.(jpg|jpeg|png|gif|ico|svg|ttf)$ {
expires 365d;
}
location ~* \.(css|js)$ {
expires 30d;
}
# Enable "Vary-Accept-Encoding" headers
# They are enabled in the nginx.conf
}
如果我删除密码保护,一切正常,管理面板也可以正常工作。我想我没有正确添加密码块。
【问题讨论】: