Creating a Rewrite Rule in JBoss

JBoss comes shipped with a Valve that allows you to do Apache mod_rewrite style URL Rewrites.

  • Under <jboss>/server/conf, create directories called jboss.web/localhost
  • Under the newly created localhost direcotry create a file called rewrite.properties with rewrite rules. For example (RewriteRule   ^/apps/(.+)  http://newappshome/$1) redirects all urls starting with /app to another server. Have a look at Appache documentation of URL Rewriting for more.
  • Edit <jboss>/server/rbs/deploy/jboss-web.deployer/server.xml and add (<Valve className="org.jboss.web.rewrite.RewriteValve" />) under the <Host> (localhost) section.
Advertisements

3 Responses to Creating a Rewrite Rule in JBoss

  1. Prakash says:

    Excellent. I had a similar issue today, and did the steps exactly you mentioned above, it worked. Thanks for posting useful information.

  2. Omar at MTV Networks says:

    Did anyone see that you made a typo in rewrite.RewriteValve? was this intentional or is it supposed to say RewriteValue with a “u”

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: