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

最新下载

热门教程

WordPress Nginx Rewrite规则详解

时间:2015-06-22 编辑:简简单单 来源:一聚教程网

发下自用的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

热门栏目