linux上布置好环境后,访问localhost正常,但是访问其他页面均报404错误,百度结果为pathinfo没有配置。试了很多个,最后还是用了我同事的配置代码才解决的。代码如下:
location / {
index index.html index.htm index.php l.php;
autoindex off;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last;
}
}
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ \.php/ {
if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_NAME $1;
fastcgi_param PATH_INFO $2;
fastcgi_param SCRIPT_FILENAME $document_root$1;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
不同的环境配置的代码可能不同,网上的版本有几种,不过差别不是很大,主要的配置代码在 location ~ .php/,有的人适用,有的人不适用,可以多试下
网友评论