How to Rewrite URLs with UrlRewriteFilter

1) Add UrlRewriteFilter to your app as described here.

2) Create the WEB-INF/urlrewrite.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
  <!-- Rewrite URLs like "http://localhost/rewritesample/sample/Hello%20World!" to "http://localhost/rewritesample/sample?msg=Hello%20World!" -->
  <rule>
    <from>^/sample/(.*)</from>
    <to>/sample?msg=$1</to>
  </rule>
</urlrewrite>

3) Deploy the app.

http://www.tuckey.org/urlrewrite/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s