Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paultuckey/urlrewritefilter
A Java Web Filter with functionality like Apache's mod_rewrite
https://github.com/paultuckey/urlrewritefilter
java-web-filter mod-rewrite rewrite-urls
Last synced: 27 days ago
JSON representation
A Java Web Filter with functionality like Apache's mod_rewrite
- Host: GitHub
- URL: https://github.com/paultuckey/urlrewritefilter
- Owner: paultuckey
- License: other
- Created: 2015-07-05T22:25:22.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-02-22T20:54:01.000Z (9 months ago)
- Last Synced: 2024-06-27T13:34:51.108Z (5 months ago)
- Topics: java-web-filter, mod-rewrite, rewrite-urls
- Language: Java
- Homepage: http://tuckey.org/urlrewrite/
- Size: 5 MB
- Stars: 333
- Watchers: 31
- Forks: 143
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# UrlRewriteFilter
### [UrlRewriteFilter Web Site](http://www.tuckey.org/urlrewrite/) | [Documentation](https://tuckey.org/urlrewrite/manual/4.0/index.html)
*Based on the popular and very useful [mod_rewrite](http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html) for apache, UrlRewriteFilter is a Java Web Filter for any J2EE compliant web application server (such as [Resin](http://caucho.com), [Jetty](https://eclipse.dev/jetty/) or [Tomcat](http://tomcat.apache.org/)), which allows you to rewrite URLs before they get to your code. It is a very powerful tool just like Apache's mod_rewrite.*
URL rewriting is very common with Apache Web Server (see [mod_rewrite's rewriting guide](http://httpd.apache.org/docs-2.0/misc/rewriteguide.html)) but has not been possible in most java web application servers. The main things it is used for are:
* URL Tidyness / [URL Abstraction](https://tuckey.org/urlrewrite/manual/4.0/guide.html#urlabs) - 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](https://tuckey.org/urlrewrite/manual/4.0/guide.html#method))!UrlRewriteFilter uses an xml file, called urlrewrite.xml (it goes into the WEB-INF directory), for configuration. Most parameters can be Perl5 style Regular Expressions or Wildcard Expressions. This makes it very powerful indeed.
See the [manual](https://tuckey.org/urlrewrite/manual/4.0/index.html) for more information.
## Quick Start
* Add Maven dependency below or add urlrewritefilter-5.1.3.jar directly into your WEB-INF/lib directory.
```xml
org.tuckey
urlrewritefilter
5.1.3
```For Servlet API 4 or less (javax), use the old version 4.x
```xml
org.tuckey
urlrewritefilter
4.0.3
```
* Add the following to your WEB-INF/web.xml (add it near the top above your servlet mappings (if you have any)): (see filter parameters for more options)
```xml
UrlRewriteFilter
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
UrlRewriteFilter
/*
REQUEST
FORWARD
```
* Add urlrewrite.xml into your WEB-INF directory. (src/main/webapp/WEB-INF/ for Maven users)
* Restart the context.You can visit http://127.0.0.1:8080/rewrite-status (or whatever the address of your local webapp and context) to see output (note: this page is only viewable from localhost).
Previously on Google Code: http://code.google.com/p/urlrewritefilter.