在网上找了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
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com