基于linux下LNMP环境设置wordpress伪静态

1.编辑配置文件

# vi /usr/local/nginx/conf/vhost/你的网站根目录.conf    
# vi /usr/local/nginx/conf/nginx.conf      在server(server模块中)中添加 include rewrite/wordpress.conf;   注意:不同端口,都需要这条配置。
# vi /usr/local/nginx/conf/rewrite/wordpress.conf     注意:你可以选择将下面代码写入wordpress.conf中,也可以选择直接写入nginx.conf的server模块中。

2.添加内容

location / {
        #try_files $uri $uri/ /index.php?$args;
        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 (.*) /index.php;
        }
}

3.在 wordpress 后台 “设置” -> “固定链接” -> 点击 “自定义结构”输入 /%post_id%.html

有帮助,想了解更多,欢迎访问我的主页秋风荡

原文地址:https://www.cnblogs.com/hjjjjhd/p/11065114.html