黑帽联盟

 找回密码
 会员注册
查看: 1833|回复: 0

[建站文章] nginx下wordpress伪静态设置

[复制链接]
yun 黑帽联盟官方人员 

920

主题

37

听众

1364

积分

超级版主

Rank: 8Rank: 8

  • TA的每日心情
    奋斗
    2019-10-18 11:20
  • 签到天数: 678 天

    [LV.9]以坛为家II

    搭建个WordPress的blog系统来玩,记录下在nginx下的伪静态规则,但nginx是不支持.htaccess文件的,所以只能写到配置里.

    1.下面是nginx的伪静态,要写在server里.
    location / {
    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;
    }
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    }

    2.然后进入后台-设置-固定链接-自定义
    /%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的固定链接形式。网上常见的几种设置方法:
    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

    您需要登录后才可以回帖 登录 | 会员注册

    发布主题 !fastreply! 收藏帖子 返回列表 搜索
    回顶部