Summary: | Would like full request evaluation support in RewriteCond | ||
---|---|---|---|
Product: | Apache httpd-2 | Reporter: | alexander <alexander> |
Component: | mod_rewrite | Assignee: | Apache HTTPD Bugs Mailing List <bugs> |
Status: | NEW --- | ||
Severity: | enhancement | ||
Priority: | P2 | ||
Version: | 2.5-HEAD | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Linux |
Description
alexander
2015-07-21 23:37:32 UTC
> 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. ErrorDocument works inside of <LocationMatch> and its argument specifies the new URL-path. It's probably easier to extend ErrorDocument then to extend mod_rewrite -- mod_rewrite never runs after a status code has been determined by whichever handler is in charge. One possible extension would be to make ErrrorDocument take an expression as an argument (as in http://httpd.apache.org/docs/2.4/expr.html) For static files, you can also work around the DOCUMENT_ROOT issue by putting your rewrites in per-directory context. The core will have mapped the URL to a filename and %{REQUEST_FILENAME} will be a filesystem path. There's also FallBackResource. whoops, ErrroDocument already supports expressions in the final parameter. Sees like most of the elements are there. Sorry for the trickle here, but perhaps one thing missing in the ErrorDocument solution is that the status code does not change. It seems like that is relatively straightfoward to implement though. I see what you mean. I had not considered using ErrorDocument via LocatioMatch, and that does indeed seem to be the way to do it. However, it doesn't seem to support one crucial thing, which is to provide the current REQUEST_URI to the ErrorDocument argument, although the docs seem to suggest this should be possible: ErrorDocument 404 /errors%{escape:%{HTTP_URI}} I would expect the above to internally rewrite the would-be 404 result to /errors/the-missing-file.txt (if http://example.org/the-missing-file.txt was requested). Apache chokes out with the message: Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request. Am I doing something wrong, or is this the one part of the puzzle that is missing, that I should do a feature request for? |