最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
NGINX重定向改为apache重定向
时间:2022-06-30 18:41:17 编辑:袖梨 来源:一聚教程网
NGINX重定向改为apache重定向例子
NGINX重定向规则
代码如下 | 复制代码 |
rewrite ^/index.(html|htm)$ /index.$1 last; rewrite ^/index_(hot|new)(_(\d+))?.html$ /index.php?ac=index&st=$1&page=$3 last; rewrite ^/index_(\d+).html$ /index.php?ac=index&page=$1 last; rewrite ^/([a-zA-Z]+)_(new|hot)(_(\d+))?.html$ /index.php?ac=$1&st=$2&tid=$4 last; rewrite ^/([a-zA-Z]+)_(new|hot)_(\d+)_(\d+).html$ /index.php?ac=$1&st=$2&tid=$3&page=$4 last; rewrite ^/([a-zA-Z]+)_(\d+)_(\d+).html$ /index.php?ac=$1&tid=$2&page=$3 last; rewrite ^/([a-zA-Z]+)(_(\d+))?.html$ /index.php?ac=$1&tid=$3 last; |
改成apache重定向之后
代码如下 | 复制代码 |
RewriteEngine On RewriteRule ^/index.(html|htm)$ http://www.xxx.com/index.$1 [R=301] RewriteRule ^/index_(hot|new)(_(\d+))?.html$ http://www.xxx.com/index.php?ac=index&st=$1&page=$3 [R=301] RewriteRule ^/index_(\d+).html$ http://www.xxx.com/index.php?ac=index&page=$1 [R=301] RewriteRule ^/([a-zA-Z]+)_(new|hot)(_(\d+))?.html$ http://www.xxx.com/index.php?ac=$1&st=$2&tid=$4 [R=301] RewriteRule ^/([a-zA-Z]+)_(new|hot)_(\d+)_(\d+).html$ http://www.xxx.com/index.php?ac=$1&st=$2&tid=$3&page=$4 [R=301] RewriteRule ^/([a-zA-Z]+)_(\d+)_(\d+).html$ http://www.xxx.com/index.php?ac=$1&tid=$2&page=$3 [R=301] RewriteRule ^/([a-zA-Z]+)(_(\d+))?.html$ http://www.xxx.com/index.php?ac=$1&tid=$3 [R=301] |
pache转换 nginx可以使用的规则:
代码如下 | 复制代码 |
RewriteEngine On |
以上为apache的伪静态规则。下面为转换后的nginx规则:
代码如下 | 复制代码 |
rewrite ^/([a-z]+)/p_([0-9]+)\.html$ /list.php?id=$1 last; |
apache后则不能直接使用点和问号,所以将/list\.php\?id=$1中的"\"去掉,即:/list.php?id=$1
将RewriteRule 换为 rewrite,并在在每条规则后加上”last;“
相关文章
- 《绝区零》伊芙琳培养材料汇总 01-24
- 《无限暖暖》1.2春节兑换码一览 01-24
- 《网上国网》查询阶梯档位方法 01-24
- 《蛋仔派对》神游贺岁盲盒获取方法 01-24
- 《炉石传说》星际联动盗贼卡组玩法介绍 01-24
- 皮革珊瑚属于珊瑚中的 01-24