wordpress主题|WordPress Nginx Rewrite规则详解

更新时间:2019-11-17    来源:WordPress    手机版     字体:

【www.bbyears.com--WordPress】

发下自用的WordPress Nginx重定向规则,适合非子目录安装:

location / {
 try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

AMH自带的为:

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

简单使用方法:AMH使用AMRewrite插件新建一条Rewrite规则,校验规则,然后编辑虚拟主机,选择新建的规则。
直接改nginx.conf了解的自然了解

另外一种nginx下WordPress固定链接的伪静态规则

nginx配置文件nginx.conf的location段添加一行就OK。

1. 打开nginx配置文件:

# vim /etc/nginx/nginx.conf(此路径根据Linux版本与安装路径会有不同)

2. 在server容器中添加下面这几行

location /
{
try_files $uri $uri/ /index.php?q=$uri&$args;
}

3. 重新加载nginx配置文件

# /etc/init.d/nginx reload

本文来源:http://www.bbyears.com/wangyezhizuo/79844.html