NGINX php-cgi环境下配置alias目录出现404错误
原因:
默认的fastcgi参数:
fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
alias后的fastcgi参数:
rewrite /p/(.*\.php?) /$1 break;
去除URL前面的“/p”,再把正确的SCRIPT_FILENAME 传给php-cgi
fastcgi_param SCRIPT_FILENAME /var/www/phpmyadmin/$fastcgi_script_name;
location /p/ {
alias /var/www/phpmyadmin/;
autoindex on;
index index.php index.shtml;
ssi on;
index index.php index.shtml index.html index.htm;
auth_basic "Restricted";
auth_basic_user_file /var/www/htpasswd;
}
location ~ ^/p/.+\.php$ {
#root /var/www/html;
rewrite /p/(.*\.php?) /$1 break;
include fcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/phpmyadmin/$fastcgi_script_name;
}
参考了:
使用中出现问题:
读取的http响应中有部份,尾部丢了,不知是何原因。
换成没用alias就好了。
阅读(1468) | 评论(0) | 转发(0) |