我的wordpress站点时https://www.xxx.com/blog,给站点制作wordpress的时候难到了我,nginx和wordpress都配置完之后,依然是404,按照官方文档加了 try_files $uri $uri/ /index.php;依然于事无补,404挥之不去,只是因为我的wordpress站点在/blog下面,没办法,需求就这样。下面看一下我的正确配置:
wordpress配置:我选择的固定链接时文章名
nginx配置:
可以看到我添加了
location /blog {
index index.html index.php;
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 (.*) /blog/index.php;
}
}
rewrite /blog/wp-admin$ $scheme://$host$uri/ permanent;
我是根据这篇文章去修改的:WordPress最佳固定链接设置 - 铭创网络 (yephy.com)https://www.yephy.com/1367.html