httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 58168] New: Would like full request evaluation support in RewriteCond
Date Tue, 21 Jul 2015 23:37:32 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=58168

            Bug ID: 58168
           Summary: Would like full request evaluation support in
                    RewriteCond
           Product: Apache httpd-2
           Version: 2.5-HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: mod_rewrite
          Assignee: bugs@httpd.apache.org
          Reporter: alexander@polkabrothers.com

I am trying to handle a situation where I need to do special things to requests
that otherwise would have turned into 404:s due to the requested resource
doesn't exist. I can do this beautifully in Nginx like so:

location some-regex { error_page 404 = @handle404; }
location @handle404 { ... }

Nginx will evaluate the request fully, and send it to the $handle404 location
block if it would have resulted in a 404.

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule "some-regex" "..."

Apache's mod_rewrite is not capable of telling me if a certain request will
result in a 404 or not, all I can do is try to guess by asking Apache to check
if the requested file exists on the hard drive under the same path as what is
in the URL.

This works if and only if a simple URL scheme like that is used, otherwise if
fails. Examples of when it fails:
- If an Alias directive is used for the requested URL
- If the request depends on subsequent rewrites to map to the correct resource
on the harddrive
- If the request maps to a dynamic script that exists, but may itself return a
404 status

So my feature request is for support to be added to mod_rewrite so we can do
the equivalent of what nginx supports with its error_page directive.
Syntactically it could work like this:

RewriteCond %{IS_404} true
RewriteRule "some-regex" "..."

Note, I am aware of Apache's ErrorDocument, but it doesn't support targeting
with regular expression, or URL rewriting, which are both things I need. This
feature seems like a natural fit in mod_rewrite.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message