发博文
网站运维与管理

http://blog.chinaunix.net/space.php?uid=522598

http://www.feiyujp.com 【航班查询|机票预订|特价机票】--飞宇机票网 010-84818062   
个人资料
  • 博客访问:437867
  • 博文数量:201
  • 博客积分:10489
  • 博客等级:上将
  • 关注人气: 1
  • 注册时间:2006-02-21 22:07:04
订阅我的博客
  • 订阅
  • 订阅到鲜果
  • 订阅到抓虾
  • 订阅到Google
字体大小: 博文


一、nginx 的rewrite测试
 
  测试实现www.test1.com/*  自动跳转到www.test2.com/*
  1. 配置代码:
  2.   server
  3.   {
  4.     listen 80;
  5.     server_name test1.com;
  6.     index index.html index.shtml index.php;
  7.     root /data/webroot/bitauto;
  8.     if ($host ~* (.*)\.test1\.com) {
  9.        set $sub_name $1;
  10.        rewrite ^/(.*)$ http://$sub_name.test2.com/$1 permanent;
  11.        }

二. squid url rewrite with jesred

1)主要配置文件

/usr/local/squid/etc/jesred.conf (设置一些配置选项)

/usr/local/squid/etc/jesred.acl (配置哪些来源的ip可以被jesred rewrite,一般设置为 0.0.0.0/0,而通过squid自身控制rewrite条件)

/usr/local/squid/etc/jesred.rules (实际的rewrite规则)

 

2. squid.conf片断:

  1. url_rewrite_program usr/local/squid/etc/libexec/jesred

  2. url_rewrite_children 20

  3. url_rewrite_host_header off

3附加说明

默认,jesred(或是其它的些rewrite工具)是作隐式的(透明地)url rewrite,即 从 url1 -> url2时,HTTP Ret Code还是会200,

客户端觉查不到有跳转的发生;

如果需要返回显示的跳转,HTTP RetCode 301或是302,即需要对rewrite规则进行小的修改

regexi ^http://(.*).163.com/(.*\.wma)\?.*       http://\1.163.com/\2  #此为隐式跳转

regexi ^http://(.*).163.com/(.*\.wma)\?.*       302:http://\1.163.com/\2  #此为显式跳转

4.测试

测试实现www.test1.com/*  自动跳转到www.test2.com/*

编辑 /usr/local/squid/etc/jesred.rules

  1. regexi ^http://www\.test1\.com/(.*)$ 301:http://www.test2.com/\1

 

 

博客推荐文章
亲,您还没有登录,请[登录][注册]后再进行评论