免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3930 | 回复: 16

[Web] apache2 RedirectMatch问题 [复制链接]

论坛徽章:
0
发表于 2007-01-08 11:35 |显示全部楼层
apache2 中能不能实现这样的重定向:
把 /test/a.jsp?c1=c10&c2=1 重定向到http://192.168.2.221/test/a.htm
把 /test/a.jsp?c1=c11&c2=1 重定向到http://192.168.2.221/test/b.htm
如果可以,那么正则表达式该怎么写?

论坛徽章:
0
发表于 2007-01-08 11:44 |显示全部楼层
有人知道吗?在这先谢谢了

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2007-01-08 12:09 |显示全部楼层
完全可以,请看:
http://man.chinaunix.net/newsoft ... /rewrite_guide.html
这个更好,搜索关键字:
从静态到动态

论坛徽章:
0
发表于 2007-01-08 13:03 |显示全部楼层

回复 3楼 HonestQiao 的帖子

我是想通过c1=c10&c2=1这两个个参数来做重定向,根据不同的c1和c2的值做重定向,老大说的这个好像不太满足我的需求呀?

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2007-01-08 13:21 |显示全部楼层
原帖由 jazzyl 于 2007-1-8 13:03 发表
我是想通过c1=c10&c2=1这两个个参数来做重定向,根据不同的c1和c2的值做重定向,老大说的这个好像不太满足我的需求呀?


apache的rerwite完全可以做到你的要求。

论坛徽章:
0
发表于 2007-01-08 13:27 |显示全部楼层
原帖由 HonestQiao 于 2007-1-8 13:21 发表


apache的rerwite完全可以做到你的要求。



如果是这样的可以吗?
http://192.168.2.1/test/?C1=DA&C2=DB 重定向到一个静态页面http://192.168.2.1/test/DADB.html
可以实现吗?

能告诉我怎么写吗?我遇到的问题是到?后面的就不做匹配了,访问的是test这个目录下的index.html

[ 本帖最后由 jazzyl 于 2007-1-8 16:54 编辑 ]

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2007-01-08 19:28 |显示全部楼层

  1. RewriteCond  %{THE_REQUEST} ^(GET|POST) /test/\?C1=([^&]+)&C2=([^&]+)\
  2. RewriteRule     ^/test/$2$3.html? [R]
复制代码

论坛徽章:
0
发表于 2007-01-09 14:36 |显示全部楼层
原帖由 HonestQiao 于 2007-1-8 19:28 发表

  1. RewriteCond  %{THE_REQUEST} ^(GET|POST) /test/\?C1=([^&]+)&C2=([^&]+)\
  2. RewriteRule     ^/test/$2$3.html? [R]
复制代码


按上面的写了还是不行,rewritelog如下:

192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f1950/initial]

(2) init rewrite engine with requested uri /test/
192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f1950/initial]

(3) applying pattern '^/test/$2$3.html?' to uri '/test/'
192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f1950/initial]

(1) pass through /test/
192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f5960/subreq]

(2) init rewrite engine with requested uri /test/index.html
192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f5960/subreq]

(3) applying pattern '^/test/$2$3.html?' to uri '/test/index.html'
192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f5960/subreq]

(1) pass through /test/index.html
192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f5960/subreq]

(2) init rewrite engine with requested uri /test/index.html.var
192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f5960/subreq]

(3) applying pattern '^/test/$2$3.html?' to uri '/test/index.html.var'
192.168.2.21 - - [10/Jan/2007:16:40:12 +0800] [192.168.2.1/sid#8331e88][rid#83f5960/subreq]

(1) pass through /test/index.html.var

论坛徽章:
0
发表于 2007-01-10 08:54 |显示全部楼层

回复 1楼 jazzyl 的帖子

好像是没有把变量传过去吧?我的http.conf中只加了如下三句,还需要其他的语句吗?
RewriteEngine on
RewriteCond  %{THE_REQUEST} ^(GET|POST) /test/\?C1=([^&]+)&C2=([^&]+)\
RewriteRule     ^/test/$2$3.html? [R]

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2007-01-10 08:58 |显示全部楼层
RewriteCond  %{THE_REQUEST} ^(GET|POST)\ /test/\?C1=([^&]+)&C2=([^&]+)\
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP