配置nginx 地址rewrite

折腾博客时发现点开所有博客链接都是404 错误,很明显是rewrite 问题。解决办法是在nginx 配置文件中顶层location 下添加如下重写规则:
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
然后重启nginx 服务即可。

Leave a Reply

Your email address will not be published. Required fields are marked *