mod rewrite clear home url for tomcat + apache

本小妞迷上赌 提交于 2019-12-08 12:18:19

问题


I have a struts app running on Apache front end of Tomcat via mod-jk.

I am trying to use mod-rewrite to clean some of the action urls generate by struts.

Example: rewrite (works fine)

http://www.demo.com/context/user.do?action=aboutus to http://www.demo.com/context/aboutus using RewriteRule ^/msn/aboutus$ /msn/user.do?action=aboutus [PT,L].

Problem: I'd like to rewrite the http://www.demo.com/context/user.do?action=home to http://www.demo.com (homepage)

I tried this RewriteRule ^/$ /context/userdo?action=home [PT,L] which does not work.

FYI

All the css,js and links are on relative path.

DirectoryIndex is on index.html (Does it change mod-rewrite behaviour?)

Tomcat Version 5.5, Application deploy via exploding the WAR file in public_html/context/ folder (multiple deployment)

URLrewrite filter does not help to remove the context name according to this.

Logs

I tired to have a look at the log file (snapshots) which doesn't give any warning error messages.

(3) applying pattern '^/$' to uri '/context/jsps/images/abc.png'
(3) applying pattern '^/abc/aboutus$' to uri '/abc/jsps/images/abc.png'   
(3) applying pattern '^/abc/home$' to uri
'/abc/jsps/images/abc.png'

Anyone can give me some ideas what went wrong? and how can I solve that issue?


回答1:


I think in your case of rewriting ^/$ it is mod_jk that is taking precedence over mod_rewrite rules since using mod_jk you are forwarding everything eg: /* to Tomcat from Apache. I will suggest using URLRewriteFilter within your Tomcat app to achieve these URL rewrites properly.



来源:https://stackoverflow.com/questions/8499727/mod-rewrite-clear-home-url-for-tomcat-apache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!