https://bz.apache.org/bugzilla/show_bug.cgi?id=62667

            Bug ID: 62667
           Summary: RewriteMap not working with %{HTTP_HOST}
           Product: Tomcat 9
           Version: 9.0.x
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: p...@itassist.no
  Target Milestone: -----

When passing %{HTTP_HOST} as the key to a RewriteMap the lookup function only
passes the path of the page «/test/tespage» and not the host «test.example.com»

The URL sent to Tomcat is: http://test.example.com/test/testpage

In our example the %{HTTP_HOST} returns test.example.com which is ok.

But referenced inside RewriteRule with input to map function it fails.

rewrite.conf:
 RewriteMap portals org.apache.catalina.valves.rewrite.EPSMapPage
/usr/local/tomcat/easier-conf/portals.txt
 RewriteRule .* ${portals:%{HTTP_HOST}}

The EPSMapPage is a rewrite map class we have made according to tomcat valve
documentation and we have checked that this class works correct.

So this portion of the RewriteRule ${portals:%{HTTP_HOST}} should feed in
test.example.com (%{HTTP_HOST}) to map portals but actually it feeds in
/test/testpage not the hostname.

org.apache.catalina.valves.rewrite.EPSMapPage
 public String lookup(String key) {
  System.out.println("Key: " + key);
  return map.get(key.substring(1));
 }
console output:
 Key: /test/testpage

When using
RewriteRule .* %{HTTP_HOST}
it works at expected And redirects to
test.example.com/test.example.com

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to