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

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


            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

First solution:

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

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"

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"

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