linux上布置好環(huán)境后,訪問localhost正常恋昼,但是訪問其他頁面均報404錯誤看靠,百度結(jié)果為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;
}
不同的環(huán)境配置的代碼可能不同,網(wǎng)上的版本有幾種嗦哆,不過差別不是很大谤祖,主要的配置代碼在 location ~ .php/,有的人適用老速,有的人不適用粥喜,可以多試下