Summary: | RewriteCond local file system checks (-f and others) should allow (sane) relative path resolution | ||
---|---|---|---|
Product: | Apache httpd-2 | Reporter: | Oded Arbel <oded> |
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
Oded Arbel
2020-05-17 11:34:38 UTC
> using relative URLs will never work if the server process current working
> directory is not somewhere under the document root.
Do you mean here still relative paths in the -f/-d tests? There are facilities for relative URLs and paths in the actual substitutions that use e.g. CONTEXT_DOCUMENT_ROOT or RewriteBase.
I think what you propose for the -d/-f would require opt-in to be suitable for release. At that point I am not sure if just providing a variable for the htaccess path is better and using it in some examples.
(special care would be needed for rewrite inside other config sections)
1. As mod_rewrite internally calculates the directory of the .htaccess and uses it, I think that it would be great to expose that to the configuration language. This would allow us to stop using weird tricks like documented here - https://stackoverflow.com/questions/21062290 - and instead just directly ask the questions we want answered. 2. CONTEXT_DOCUMENT_ROOT is different than document root only in very specific conditions and require server-level configuration - completely out of scope from people writing .htaccess files. RewriteBase assumes that the application writer knows the full path from the document root to the application, which is often not the case when a less technical user downloads an open source application - see the above StackOverflow link for some context. I'm not familiar with any way to resolve relative paths without access to server configuration or pre-knowledge of the path structure of the website - both kind of negate the need for relative paths. 3. Because the current relative path resolution behavior in mod_rewrite is completely unexpected and unreliable in the scope of .htaccess, and also can never expected to work in common configurations (such as under Debian and Fedora/RedHat where httpd is run with cwd set to /), I don't believe there is existing setups that rely on the current behavior. That being said, if the behavior suggested in this report can be triggered by a RewriteOption, that would be good enough. |