Link to my previous question, I want to rewrite the http://www.demo.com/context/user.do?action=home
to http://www.demo.com
, and was advised to try URLRewriteFilter.
The following code
<rule>
<from>^/$</from>
<to type="redirect">%{context-path}/user.do?action=home</to>
</rule>
does not removes the context name, that is I still need to enter from http://www.demo.com/context/
Given all the example in the official site is based on top of the context, is the RewriteFilter really the right tool to solve the initial problem?
You need to deploy the webapp on the context root instead. Either rename the WAR to
ROOT.war
(and remove the default/ROOT
folder in Tomcat's webapps, if any) so that Tomcat will autodeploy it on root, or edit the<Context>
element of the webapp'scontext.xml
to specifypath=""
instead ofpath="/context"
.The rewrite filter runs at webapp level only, not at Tomcat level, so trying to use it to change the webapp's context path (which is by itself to be configured at Tomcat level) makes no sense.
See also: