2 Replies Latest reply on Oct 1, 2009 4:22 AM by Jean-Frederic Clere

    rewritevalve substitution class with odd results

    David Reed Newbie

      I have 4.2.2 GA of JBoss Application Server that is using the rewritevalve from the web server. I also have a couple of custom RewriteMap classes and in one of them I am doing something similar to the vhost found within Apache's version of mod_rewrite. The only problem is that somehow the line from the rewrite properties isn't getting filled in correctly.

      Here is a snippet of my rewrite.properties file:

      #
      # define two maps: one for fixing the URL and one which defines the
      # available virtual hosts with their corresponding DocumentRoot.
      #
      RewriteMap lowercase custom.rewrite.ToCase lower
      RewriteMap vhost custom.rewrite.VHost c:/jboss422/conf/vhost.map
      #
      # 1. make sure we have a Host header, because currently our approach
      # only supports virtual hosting through this header
      #
      RewriteCond %{HTTP_HOST} !^$
      RewriteCond %{HTTP_HOST} !^null$
      #
      # 2. remove the :port value from the HTTP_HOST if it is there
      #
      RewriteCond %{HTTP_HOST} ^([^:]*).*$
      #
      # 3. lowercase the vanity name
      #
      # "%1" back-references to the last matched RewriteCond pattern
      #
      RewriteCond ${lowercase:%1|default.com} ^.*$
      #
      # 4. lookup this hostname in vhost.map and remember it
      #
      # "%1" back-references to the last matched RewriteCond pattern
      #
      RewriteCond ${vhost:%1} ^(/.*)$
      


      Everything works great up until the the RewriteCond line using the lowercase map. The %1 should get replaced by the result from the previous RewriteCond, but it doesn't. It actually goes through where the key in the custom RewriteMap class is actually "%1", minus the quotes.

      I also tried a line like the following:

      RewriteCond ${lowercase:%{HTTP_HOST}|default.com} ^.*$
      


      But that even through a weird error from line 158 in the Substition.parse class and method. It shouldn't even have been in there as there was both a '$' and a '%' in the line.

      I have System.err.println statements in the custom RewriteMap and it is reading the vhost.map file correctly, but the key isn't correct.

      Any ideas?