浏览 4346 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-07-20
不用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 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |