一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

wordpress在nginx下的rewrite规则写法

时间:2013-11-05 编辑:简简单单 来源:一聚教程网

wordpress在nginx下的rewrite规则写法:

[root@localhost ~]# cat /etc/nginx/wprw.conf

 代码如下 复制代码

rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;

if (!-e $request_filename) {

rewrite ^.+?(/wp-.*) $1 last;

rewrite ^.+?(/.*.php)$ $1 last;

rewrite ^ /index.php last;

}

配置Nginx服务器:

nginx rewrite for wordpress

nginx rewrite for wordpress

 然后进入后台-设置-固定链接-自定义

 代码如下 复制代码
/%category%/%post_id%.html


首先我们看看wordpress官方列出的部分可以使用的固定链接基本参数:
%year%
基于文章发布年份,比如2009;
%monthnum%
基于文章发布月份,比如12;
%day%
基于文章发布当日,比如28;
%hour%
基于文章发布小时数,比如15;
%minute%
基于文章发布分钟数,比如43;
%second%
基于文章发布秒数,比如33;
%postname%
基于文章的postname,其值为撰写时指定的缩略名,不指定缩略名时是文章标题;
%post_id%
基于文章post_id,比如888;
%category%
基于文章分类,子分类会处理成”分类/子分类”这种形式;
%author%
基于文章作者名,如rocdk890.

设置wordpress固定链接作测试:

Custom Links

Custom Links

那么,该我们展示效果了吧。呵呵,不好意思,来个了 .fuck 的后缀。。。

Hello world one

Hello world one


将上述参数进行组合,即可得到wordpress的固定链接形式。网上常见的几种设置方法:

 

 代码如下 复制代码
1./%year%/%monthnum%/%day%/%postname%/
2./%year%/%monthnum%/%postname%/
3./%year%/%monthnum%/%day%/%postname%.html
4./%year%/%monthnum%/%postname%.html
5./%category%/%postname%.html
6./%post_id%.html

热门栏目