Nginx下配置wordpress伪静态规则

654 查看

需要在站点配置文件中添加wordpress伪静态规则:

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;
  }
}

然后重启nginx;

后台在设置/固定链接设置添加自定义链接规则即可,例如:

http://a.com/%year%/%monthnum%/%postname%.html


原文链接:http://www.zhouyalin.com/2015/12/24/nginx%E4%B8%8B%E9%85%8D%E7%BD%AEwordpress%E4%BC%AA%E9%9D%99%E6%80%81%E8%A7%84%E5%88%99.html