httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett Delle Grazie <>
Subject [users@httpd] mod_rewrite internal sub-request returns status 200 instead of expected 404 (mod_proxy issue?)
Date Thu, 03 Sep 2009 17:34:57 GMT

I've got the following situation:

RHEL5.3 with Apache 2.2.3

Two servers (A + B), with A acting as a reverse proxy for B via Apache's

Internet --> A (mod_proxy) --> B

The entire /content/ URL space is mapped and this is working just fine.

For a specific request to A that results in a 404 from B I need to:
Submit another request (i.e. not a client side redirect) to A via
another virtual host configuration of a rewritten URL.  This sub-request
may result in having output filters applied to transform content from
one type to another.

What's the best way of doing this?

The problem appears to be that the physical documents reside on B but I
want the transformation / processing performed on A.

I've tried the sub-request mechanism of mod_rewrite (via !-U condition)
but the sub-request always returns status 200 instead of 404 (even
though the first document doesn't exist on B).

Does anyone know if this is an existing bug with mod_rewrite or is this
expected behaviour?

I realise this could probably be done best by an ErrorDocument handler
but I'm not sure how to do the request to localhost:81 via a perl cgi
script in such a way as to not cause issues.

Any help or pointers in the right direction would be appreciated.


Best Regards,


My current solution (failing) looks something like this:

<VirtualHost _default_:80>
    <Proxy *>
      Order allow,deny
      Allow from all

    RewriteEngine on
    RewriteOptions inherit

    #Contrived example - anything with extension .notfound does not
exist on B (results in 404)
    RewriteCond %{REQUEST_URI} ^(.+)\.notfound$
    # According to docs !-U should fail but it returns status 200
    RewriteCond %{REQUEST_URI} !-U
    RewriteRule ^(.+)\.notfound?$  http://localhost:81/$1.found [L,P]

    # Proxy requests to B
    ProxyRequests Off
    ProxyErrorOverride on
    ProxyPass /content/ http://B/content/
    ProxyPassReverse /content/ http://B/content/

This email has been scanned by the MessageLabs Email Security System.
For more information please visit 

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message