增加nginx规则让wordpress的链接变得好看,支持设置Numeric

       很简单,打开NGINX的配置文件,可能是conf/nginx.conf,或者vhost.conf,或者是 virtual.conf  ,就看你的域名是配在什么地方了。然后,在‘location /’段中增加一行“try_files $uri $uri/ /index.php?q=$uri&$args;”,即可。
      例如我的增加那一行后,样子是
    location / {
        root   /usr/share/nginx/html/wwwroot/www.lekang100.com;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }
      确认无误,重启nginx。另外,先用$ngixpath/nginx -t确认一下配置是否正确,提示configuration file $nginxconfpath/nginx.conf test is successful,就说明配置没有问题。放心的重启nginx就行了。
      重启后,就可以进入wordpress后台,进入Permalink ,把连接格式设置成Numeric,或者在Custom Structure ,修改成你想要的样子,只要末尾是/%post_id%即可。

This entry was posted in 技术文章. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>