配置目标:
1、当存在file.php时,访问/file.html和/file.php都实际访问file.php
2、当不存在file.php时,访问/file.html和/file.php返回指定的404页
3、访问其它不存在的文件时,返回相同的404页
目前的配置:
location / {
root xxx;
index xxx;
rewrite ^/(.*)\.html /$1.php last;
}
location ~ \.php {
fastcgi_pass xxx
...
}
error-page 404 /error-404.html;
location /error-404.html {
root xxx;
internal;
}
目前配置的情况:
1、目标1实现
2、目标3实现
3、当不存在file.php时,访问/file.html和/file.php没有返回指定的404页,只是404码
我个人的分析是,请求/file.html时,被重写为/file.php,当请求传给fastcgi之后找不到文件,就不再回来用404页面了,是否有办法让fastcgi部分也有个404页呢?
尝试使用 try_files:
location ~ ^/(.*)\.html {
try_files /$1.php @error;
}
location @error {
root xxx;
index error-404.html
}
存在file.php的情况下,访问/file.html返回php文件,没有交给fastcgi就返回了
--
FROM 222.131.80.*