A reescrita do URL do Tomcat falha com o 404, mas a navegação retorna diretamente a 200

4

Eu tenho um aplicativo da Web implantado em webapps/appname e estou tentando adicionar regras de reescrita a example.org/appname-slow para reescrever em example.org/appname?delay=1 . Eu tenho o seguinte em webapps/ROOT/WEB-INF/web.xml

<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>

    <init-param>
        <param-name>confReloadCheckInterval</param-name>
        <param-value>0</param-value>
    </init-param>

    <init-param>
        <param-name>statusEnabledOnHosts</param-name>
        <param-value>*</param-value>
    </init-param>

    <init-param>
        <param-name>logLevel</param-name>
        <param-value>sysout:DEBUG</param-value>
    </init-param>

</filter>

<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

e o seguinte em webapps/ROOT/WEB-INF/urlrewrite.xml :

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
    "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">

<urlrewrite use-context="true">

    <rule match-type="regex">
        <from>^/appname-slow/(.*)$</from>
        <to type="forward" qsappend="true">/appname/$1?delay=1</to>
    </rule>

</urlrewrite>

mas quando vou para o novo URL, obtenho:

HTTP Status 404 - /appname/
type Status report
message /appname/
description The requested resource is not available.

E ir diretamente para /appname/ funciona como esperado.

Em context.xml tenho

<Context crossContext="true">

em catalina.out , esta é a saída do log

org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: starting conf reload check
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: conf is not modified
org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG: looking for hostname match on current server name test.example.org
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: checking for status path on /appname-slow/
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing request for /appname-slow/
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 0 run called with /appname-slow/
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
org.tuckey.web.filters.urlrewrite.substitution.MatcherReplacer DEBUG: found 1
org.tuckey.web.filters.urlrewrite.substitution.MatcherReplacer DEBUG: replaced sb is /appname/?delay=1
org.tuckey.web.filters.urlrewrite.RuleExecutionOutput DEBUG: needs to be forwarded to /appname/?delay=1
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: starting conf reload check
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: conf is not modified
org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG: looking for hostname match on current server name test.example.org
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: checking for status path on /appname/
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing request for /appname/
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 0 run called with /appname/

O que estou perdendo?

    
por R. S. 10.02.2013 / 23:54

1 resposta

0

Depois de olhar para isso com novos olhos, eu tenho a regra to definida incorretamente para o encaminhamento de contexto cruzado.

Configurando para

<to type="forward" qsappend="true" context="appname">/$1?delay=1</to>

e funciona corretamente! Booya!

    
por 20.02.2013 / 01:54