apache+tomcat配置url rewrite 的怪问题

在网上找了N多的配置说明,终于配起来了,
不用url rewrite都一切正常,
但是当我配了url rewrite后,如:
RewriteRule ^/a.html$ /ps/index.action?hid=a [PT]
RewriteRule ^/c.htm$ /ps/index.action?hid=a [PT]

(我项目的根目录下有a.html,但不存在c.html)
在地址栏打入localhost/a.html,直接显示a.html
打入localhost/c.html,提示找不到c.html页面

我看了RewriteLog,
127.0.0.1 - - [20/Jul/2007:14:44:22 +0800] [a.duoduo.cn/sid#77e200][rid#9ab020/initial] (2) rewrite '/c.htm' -> '/ps/index.action?hid=a'
127.0.0.1 - - [20/Jul/2007:14:44:22 +0800] [a.duoduo.cn/sid#77e200][rid#9ab020/initial] (3) split uri=/ps/index.action?hid=a -> uri=/ps/index.action, args=hid=a
127.0.0.1 - - [20/Jul/2007:14:44:22 +0800] [a.duoduo.cn/sid#77e200][rid#9ab020/initial] (2) forcing '/ps/index.action' to get passed through to next API URI-to-filename handler

按道理都已经转过去了,为什么tomcat还是去拿地址栏里的地址去显示

如果我配置改成
RewriteRule ^/a.html$ /ps/index.action?hid=a [R]
RewriteRule ^/c.htm$ /ps/index.action?hid=a [R]
一切都是正常,但是这样只是起到重定向的效果,地址栏也变了,


<VirtualHost *:80>
ServerAdmin admin@abc.cn
DocumentRoot E:/Web
#您的站点项目所在路径,应与tomcat中的目录设置相同
ServerName www.abc.cn
ServerAlias *.abc.cn
ErrorLog logs/shsc-error_log.txt
CustomLog logs/shsc-access_log.txt common
RewriteLog logs/rewrite.log
RewriteLogLevel 3
JkMount /*.jsp ajp13
#让Apache支持对jsp传送,用以Tomcat解析
JkMount /*.action ajp13
#让Apache支持对.do传送,用以Tomcat解析
<Directory />
Options FollowSymLinks
AllowOverride All
Allow from all

</Directory>
RewriteEngine On

RewriteRule ^/c\.html$ /a.html [PT]
RewriteRule ^/e\.html$ /a.jsp [PT]
RewriteRule ^/f\.html$ /index.action [PT]

</VirtualHost>
RewriteRule中,第一句能正常执行,第二,三句都出现tomcat的404错误,
后来经过反复测试,发现原因是
JkMount /*.jsp ajp13
#让Apache支持对jsp传送,用以Tomcat解析
JkMount /*.action ajp13


我在这里加入一条
JkMount /*.htm ajp13

RewriteRule ^/g\.html$ /a.htm [PT]

a.htm文件是存在的,然后访问www.abc.com/g.html,还是提示tomcat的404错误,但是我直接通过www.abc.com/a.htm或www.abc.com/a.jsp都是正常的,

是不是我的重写错误,导致传入tomcat的地址是错误的?
但通过rewrite.log,发现我取的地址都是对的
127.0.0.1 - - [20/Jul/2007:14:44:22 +0800] [a.duoduo.cn/sid#77e200][rid#9ab020/initial] (2) forcing '/a.htm' to get passed through to next API URI-to-filename handler
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值