Summary
I am having trouble getting UrlRewriteFilter up and running on Tomcat.
Problem
I can only get one of the two rules from the default urlrewrite.xml file to work. I followed the installation directions without much of a problem and I haven’t changed any defaults or messed with the configuration file.
Example
The outbound rule works: http://localhost:8080/mysite/rewrite-status successfully takes me to a description page of my urlrewrite.xml file.
But the regular rule doesn’t work: http://localhost:8080/mysite/test/status does not redirect me to http://localhost:8080/mysite/rewrite-status. I get a 404 result.
Am I expecting the wrong thing from these rules? What could be wrong?
Details
Here is the urlrewrite.xml file that comes with the installation:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
"http://www.tuckey.org/res/dtds/urlrewrite3.2.dtd">
<urlrewrite>
<rule>
<note>
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
</note>
<from>/test/status/</from>
<to type="redirect">%{context-path}/rewrite-status</to>
</rule>
<outbound-rule>
<note>
The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
the url /rewrite-status will be rewritten to /test/status/.
The above rule and this outbound-rule means that end users should never see the
url /rewrite-status only /test/status/ both in their location bar and in hyperlinks
in your pages.
</note>
<from>/rewrite-status</from>
<to>/test/status/</to>
</outbound-rule>
</urlrewrite>
Does adding or removing trailing forward slash (/) make a difference? Could experiment with setting it in both or either for the from and to tags of rule tag set.