- 使用zblogPhp中的静态管理中心插件来伪静态,如图所示
server {
listen 80;
server_name www.dailyflower.club dailyflower.club;
root "C:/phpstudy_pro/WWW/dailyflower";
location / {
index index.php index.html;
include C:/phpstudy_pro/WWW/dailyflower/nginx.htaccess;
autoindex on;
#贴入它所推荐代码
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;
}
}
结果:出现index.html 页面,具体原因应该是以上代码的匹配规则的问题,Nginx Rewrite规则语法 参考如下
https://blog.csdn.net/u011598153/article/details/48181519
- 正确的解决方式: 换成如下代码就行了
参考:https://blog.csdn.net/qq_33862644/article/details/78174041
# 伪静态配置
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
4.总算解决了伪静态的问题,记录一下
- 经测试:官方推荐的去掉前两个if后也是可以用的,应该是正则表达式的拦截
server {
listen 80;
server_name www.dailyflower.club dailyflower.club;
root "C:/phpstudy_pro/WWW/dailyflower";
location / {
index index.php index.html;
include C:/phpstudy_pro/WWW/dailyflower/nginx.htaccess;
autoindex on;
#只剩下第三个if
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}



