Lately I have been digging in to application development for the Google App Engine running Open BlueDragon.  I encountered a need to rewrite and filter some URL’s.

The software: UrlRewriteFilter  (go get it here)  I used the Beta 3.2 version.

The Installation: (borrowed in part from tuckey.org’s instructions)

  1. Move the urlrewrite.xml to the /war/WEB-INF directory.
  2. Move the urlrewrite-3.2.0.jar to the /war/WEB-INF/lib directory.
  3. Add the following to your /war/WEB-INF/web.xml.
            <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>
            </filter-mapping>
            
  4. Add your own configuration to the /war/WEB-INF/urlrewrite.xml that was created.
  5. Re-deploy your Google App.

Examples:

     <!--Redirect one url-->
        <rule>
            <from>/some/old/page.html</from>
            <to type="redirect">/very/new/page.html</to>
        </rule>

  <!--  Redirect a directory -->
        <rule>
            <from>/some/olddir/(.*)</from>
            <to type="redirect">/very/newdir/$1</to>
        </rule>

   <!-- Clean a url -->
        <rule>
            <from>/products/([0-9]+)</from>
            <to>/products/index.jsp?product_id=$1</to>
        </rule>
   <!--
    eg, /products/1234 will be passed on to /products/index.jsp?product_id=1234 without the user noticing.
   -->
    <!-- Browser detection -->
        <rule>
            <condition name="user-agent">Mozilla/[1-4]</condition>
            <from>/some/page.html</from>
            <to>/some/page-for-old-browsers.html</to>
        </rule>