现在的位置: 首页 > 综合 > 正文

nginx 域名rewrite跳转

2012年06月26日 ⁄ 综合 ⁄ 共 308字 ⁄ 字号 评论关闭

◆ 需求:nginx规则,所有对OA.bccom.info的访问,redirect到uc.qycn.com,谢谢。
◆ 写法:
server
   {
   listen 80;
   server_name uc.qycn.com;
   index index.htm index.php;
   root  /export/home/www
   if ($host = "oa.bccom.info"){
   rewrite ^/(.*)$ http://uc.qycn.com/$1 permanent;
    }
}

【符号注释】
^ 匹配字符串的开始
/ 匹配域名的分隔符
. 匹配除换行符以外的任意字符
* 重复零次或更多次
(.*) 匹配任意字符
.* 匹配任意文本
$ 匹配字符串的结束

抱歉!评论已关闭.