Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a web application deployed in webapps/appname and I'm trying to add in rewrite rules to example.org/appname-slow to rewrite to example.org/appname?delay=1. I have the following in 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>

and the following in 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>

but when I go to the new url, I get:

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

And going directly to /appname/ works as expected.

In context.xml I have

<Context crossContext="true">

in catalina.out this is the log output

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/

What am I missing?

share|improve this question
    
IS not a split DNS problem? how is your hostname resolved on your workstation and server? Are different IP's? Do you have in your hosts file different configuration? –  Sacx Feb 15 '13 at 8:12
    
Hostname resolves to the same server on both sides, Host files are standard (empty except for localhost). Tomcat access logs shows the hit to /appname-slow and it returning a 404 internally. –  kormoc Feb 15 '13 at 18:37
    
My understanding urlrewrite is entirely interprocess and doesn't proxy out again. –  kormoc Feb 15 '13 at 18:41
    
As the re-write is expecting an index file to host the query string ... you might try adding a welcome file list –  Eddie B Feb 16 '13 at 16:03
    
Hrm. So the rewrite won't follow the welcome list for the new target app location? –  kormoc Feb 16 '13 at 19:29

1 Answer 1

up vote 0 down vote accepted

After looking at this with fresh eyes, I has the to rule set incorrectly for cross context forwarding.

Setting it to

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

and it works correctly! Booya!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.