-
Notifications
You must be signed in to change notification settings - Fork 0
RewriteModule
Hamed Abdollahpour edited this page Sep 19, 2013
·
2 revisions
Allows you to rewrite URLs before they get to your code. It is a very powerful tool just like Apache's mod_rewrite.
Example 1:
<module>
<name>rewrite</name>
<author>Hamed Abdollahpour</author>
<class>ir.xweb.module.RewriteModule</class>
<properties>
<property key="/start" value="index.html" />
<property key="/download/(.*)" value="/api?api=resource&download=public/" />
</properties>
</module>
URL rewriting is very common with Apache Web Server (see mod_rewrite's rewriting guide) but has not been possible in most java web application servers. The main things it is used for are:
- URL Tidyness / URL Abstraction - keep URLs tidy irrespective of the underlying technology or framework (JSP, Servlet, Struts etc).
- Browser Detection - Allows you to rewrite URLs based on request HTTP headers (such as user-agent or charset).
- Date based rewriting - Allows you to forward or redirect to other URL's based on the date/time (good for planned outages).
- Moved content - enable a graceful move of content or even a change in CMS.
- Tiny/Friendly URL's (i.e. blah.com/latest can be redirected to blah.com/download/ver1.2.46.2/setup.exe)
- A Servlet mapping engine (see Method Invocation)
- This document based on UrlRewriteFilter project
This filter has been mentioned at:
- Transparentl y Feedburning Pebble with UrlRewriteFilter
- heute-morgen.de (parametrized View State with JSF)
- Erik Isaksson's Blog (sample rules)
- Magician (use with forumnuke, in Chinese),
- Russell Beattie's Notebook.
- Some small tricks for UrlRewriteFilter http://themindstorms.wordpress.com/2006/03/25/some-small-tricks-for-urlrewritefilter/
- More...