今天遇到一个问题,发现两个404页面最终跳转的地址不一样。
现象
日常环境
https://a.test/ziliao 跳转到 https://a.test/not/found
https://a.test/ziliao/1 不跳转,直接渲染出 404 页面
预发环境
https://a.test/ziliao 跳转到 https://a.test/not/found
https://a.test/ziliao/1 跳转到 b.test
故障定位
发现问题,原来日常环境tengine.conf
里面没有配置error_page 404
,而预发上配置的是
error_page 404 https://b.test
那么当前域下的/not/found/
是怎么出来的呢?省略掉其他不相关的代码,最后如下
class Bootstrap extends \Yaf\Bootstrap_Abstract
{
function _initRoute()
{
$router = new \Yaf\Extras\RESTfulRouter(true);
$router->on('*', '.*', 'error', 'notFound');
}
}