apache+tomcat配置url rewrite 的怪问题
在网上找了N多的配置说明,终于配起来了,不用url rewrite都一切正常,
但是当我配了url rewrite后,如:
RewriteRule ^/a.html$ /ps/index.action?hid=a
RewriteRule ^/c.htm$ /ps/index.action?hid=a
(我项目的根目录下有a.html,但不存在c.html)
在地址栏打入localhost/a.html,直接显示a.html
打入localhost/c.html,提示找不到c.html页面
我看了RewriteLog,
127.0.0.1 - - (2) rewrite '/c.htm' -> '/ps/index.action?hid=a'
127.0.0.1 - - (3) split uri=/ps/index.action?hid=a -> uri=/ps/index.action, args=hid=a
127.0.0.1 - - (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
RewriteRule ^/c.htm$ /ps/index.action?hid=a
一切都是正常,但是这样只是起到重定向的效果,地址栏也变了,
<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
RewriteRule ^/e\.html$ /a.jsp
RewriteRule ^/f\.html$ /index.action
</VirtualHost>
RewriteRule中,第一句能正常执行,第二,三句都出现tomcat的404错误,
后来经过反复测试,发现原因是
JkMount /*.jsp ajp13
#让Apache支持对jsp传送,用以Tomcat解析
JkMount /*.action ajp13
我在这里加入一条
JkMount /*.htm ajp13
RewriteRule ^/g\.html$ /a.htm
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 - - (2) forcing '/a.htm' to get passed through to next API URI-to-filename handler
页:
[1]