jeudi 13 août 2015

Route URL containing ".." when on localhost in tomcat

I'm using Tomcat 8 and UrlReWriteFiler. I have a strange request and without getting into too much detail I need to enable tomcat running on a local machine to route localhost:8080/project/.. to localhost:8080/project/data.

I'm trying to get a hello world example running. I realize this is a non-standard requirement but the issue comes from an application that runs plugins in a different environment looking for a file in a folder relative to the current folder "..".

I'm looking to enable the development of a plugin on a local machine by routing anything from localhost:8080/project/.. to localhost:8080/project/data.

urlwrite.xml:

<urlrewrite>
    <rule>
        <name>Dev Development</name>
        <condition name="host" operator="equal">^localhost:8080/.*/..</condition>
        <from>^localhost:8080/(.*)/\.\.$</from>
        <to type="permanent-redirect" last="true">http://localhost:8080/$1/data</to>
    </rule>
</urlrewrite>

web.xml:

<web-app id="simple" version="2.4">

  <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>
      <dispatcher>REQUEST</dispatcher>
      <dispatcher>FORWARD</dispatcher>
  </filter-mapping> 

   <welcome-file-list>
        <welcome-file>hello.html</welcome-file>
    </welcome-file-list> 
    <servlet>
        <servlet-name>Hello</servlet-name>
        <servlet-class>Hello</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Hello</servlet-name>
        <url-pattern>/data</url-pattern>
    </servlet-mapping>
</web-app>




Aucun commentaire:

Enregistrer un commentaire