TOMCAT URL REWRITE USING URLREWRITEFILTER BY TUCKEY.ORG
In order to rewrite URL directly from the TOMCAT ROOT context:
1. Copy the urlrewritefilter-4.0.3.jar file to {TOMCAT_HOME}/lib folder
2. Add urlrewrite.xml file in the {TOMCAT_HOME}/webapps/ROOT/WEB-INF folder and write your own rule something like:
<urlrewrite>
<rule>
<from>^/([a-z]+)/some_app</from>
<to type="redirect">/other_app/LoginServlet?param1=$1</to>
</rule>
</urlrewrite>
3. If you are redirecting the url from your app, then add these line at the top of the web.xml file's Servlet mapping, for ROOT redirect, add these to ROOT/WEB-INF/web.xml file as:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
4. Now access the page using http://localhost:8090/abc/some_app, this will redirect the page to http://localhost:8090/other_app/LoginServlet?param1=abc
More information and tutorials on: http://www.tuckey.org/urlrewrite/
In order to rewrite URL directly from the TOMCAT ROOT context:
1. Copy the urlrewritefilter-4.0.3.jar file to {TOMCAT_HOME}/lib folder
2. Add urlrewrite.xml file in the {TOMCAT_HOME}/webapps/ROOT/WEB-INF folder and write your own rule something like:
<urlrewrite>
<rule>
<from>^/([a-z]+)/some_app</from>
<to type="redirect">/other_app/LoginServlet?param1=$1</to>
</rule>
</urlrewrite>
3. If you are redirecting the url from your app, then add these line at the top of the web.xml file's Servlet mapping, for ROOT redirect, add these to ROOT/WEB-INF/web.xml file as:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
4. Now access the page using http://localhost:8090/abc/some_app, this will redirect the page to http://localhost:8090/other_app/LoginServlet?param1=abc
More information and tutorials on: http://www.tuckey.org/urlrewrite/
No comments:
Post a Comment