在给朋友做网站数据库转移的时候发现的,就是伪静态出现.php的时候,会不指向index.php,翻遍了很多文档都没有找到解决办法。最后,我将问题转换了一下,先设定404的默认页面为/404.html,然后再判断返回的链接是否等于404.html,从而做跳转。废话不多说,上代码:
# 原定义的伪静态 location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } } # 将404链接指定到伪静态路径上去 location = /404.html { rewrite ^(.*)$ /index.php?s=$1 last; break; } # 定义404页面链接为/404.html error_page 404 /404.html;