git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug 62418] New: Be able to apply directives to a single file


https://bz.apache.org/bugzilla/show_bug.cgi?id=62418

            Bug ID: 62418
           Summary: Be able to apply directives to a single file
           Product: Apache httpd-2
           Version: 2.5-HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Core
          Assignee: bugs@xxxxxxxxxxxxxxxx
          Reporter: hontvari@xxxxxxxxxxxx
  Target Milestone: ---

I had to apply an ExpiresDefault directive to a single file. This is
surprisingly difficult and differ between Apache versions. I have come up with
two solutions, see
https://serverfault.com/questions/914295/how-to-apply-an-expiresdefault-directive-to-a-single-file-excluding-similar-fil/914443#914443

First solution:

<If "%{REQUEST_FILENAME} == '%{DOCUMENT_ROOT}/index.html'">
    ExpiresDefault "access plus 1 hours"
</If>

This works in a .htaccess file, but it is awkward, because the right side of
the condition must include the path to the .htaccess file. The directory should
be implicit from the location of the .htaccess. This example is the best case,
in a  wronger case the expression would be something linke
%{DOCUMENT_ROOT}/alfa/beta/index.html, if the .htaccess file is in alfa/beta.

The second solution:
<DirectoryMatch "^/srv/www-example-com/[^/]*$">
    <Files "index.html">
        ExpiresDefault "access plus 1 hours"
    </Files>
</DirectoryMatch>

This does not work in .htaccess. It is also very verbose. 

It also shows a bug in this Apache HTTPD version (2.4.18): DirectoryMatch
matches the full path of URL, including the last file name part. This is why
the closing /[^/]* expression is required before the $ sign. Otherwise it would
not match the www.example.com/index.html URL.

What I would expect is something like:

<File file1 file2 file3>
    ExpiresDefault "access plus 1 hours"
</File>

which does not match files in subdirectories, only the current directory in
.htaccess. it works for multiple files, and it is short. If used in a virtual
host context, then file1 must include the absolute path.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: bugs-help@xxxxxxxxxxxxxxxx




( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache2-bugs/msg02812.html on line 133
Call Stack
#TimeMemoryFunctionLocation
10.0008368472{main}( ).../msg02812.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache2-bugs/msg02812.html on line 133
Call Stack
#TimeMemoryFunctionLocation
10.0008368472{main}( ).../msg02812.html:0