每个文件都传递给“index.php”,但由于fastcgi,每个php文件都没有正确重定向。任何解决方法?
location / {
if ($request_filename ~* "index.php") {
break;
}
rewrite ^/(.*)$ /index.php?page=$1 last;
break;
}
location ~* \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
由于
答案 0 :(得分:2)
这是我的工作配置:
location /media {
if (-f $request_filename) {
# filename exists, so serve it
break;
}
if (-d $request_filename) {
# directory exists, so service it
break;
}
rewrite ^/(.*)$ /media/index.php?$1;
}
它会重定向所有不存在的请求,并且通常会向index.php返回404错误