Nginx URL跳转

配置需求

注:$document_uri  表示访问的url
需求:访问 www.abc.com  请求到 www.abc.com/abc/

使用操作

1、在nginx配置文件中加入

if ($document_uri !~ 'abc')
{
    rewrite ^/(.*)$ http://www.abc.com/abc/$1 permanent;
}
配置文件
    而不是单独加一句  rewrite ^/(.*)$ http://www.abc.com/abc/$1 permanent;
    如果只加rewrite 规则,而不限定条件,那么会造成死循环。  会访问到   http://www.abc.com/abc/abc/abc/abc/....
说明

 

posted @ 2018-01-31 20:43  kevin.Xiang  阅读(3339)  评论(0编辑  收藏  举报