WordPress博客程序URL静态化

WordPress博客程序URL静态化

打开wordpress后台管理界面:设置-固定链接-自定义结构中输入:/archives/%post_id%.html - 保存。

[root@web01 ~]# cd /application/nginx/conf/extra/

[root@web01 extra]# vim blog.conf  #编辑nginx的blog的配置文件

  server {

        listen       80;

        server_name  blog.etiantian.org;

        location / {

            root   html/blog;

            index  index.php index.html index.htm;

        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;

        }

        }

        location ~ .*\.(php|php5)?$ {

            root html/blog;

            fastcgi_pass 127.0.0.1:9000;

            fastcgi_index index.php;

            include fastcgi.conf;

       }

  }

或者添加以下代码:

location / {

try files $uri $uri/ /index.php?q=$uri&$args;<br></span>

[root@web01 extra]# /application/nginx/sbin/nginx -t  #检查语法

[root@web01 extra]# /application/nginx/sbin/nginx -s reload  #平滑重启nginx

测试:写一篇博文测试

猜你喜欢

转载自blog.csdn.net/qq_41816540/article/details/81276099