mod_headers module does not load, though it's enabled in httpd.conf

11,230

You need to check for the mod_headers.c module:

<IfModule mod_headers.c>

(See this answer about the .so/.c stuff)

But the reason you're getting the 500 error is twofold.

First, the <FilesMatch> container expects a regular expression, and "*.gif" isn't a valid regular expression. You probably just want to use the <Files> container.

Second, the <If> isn't available in apache 2.2, only version 2.4. If you aren't using apache 2.4, then you're not going to be able to use the <If> container.

Share:
11,230
Tomáš Zato
Author by

Tomáš Zato

It might be easier to hire new management than to get a new community of volunteers. - James jenkins If you play League of Legends, check my repository: http://darker.github.io/auto-client/ I no longer play and I am actively looking for someone to maintain the project. It helped thousands of people, literally.

Updated on June 04, 2022

Comments

  • Tomáš Zato
    Tomáš Zato about 2 years

    I need mod_headers to force download of a file depending on GET parameter.

      <FilesMatch "*.gif">
         <If "%{QUERY_STRING} =~ /dl/">
            #Download header
            Header set Content-Disposition "attachment"
         </If>
      </FilesMatch>
    

    Code above produces an error 500. However, if I wrap it properly in <IfModule>, it does not do anything at all:

    <IfModule mod_headers>
      <FilesMatch "*.gif">
         <If "%{QUERY_STRING} =~ /dl/">
            Header set Content-Disposition "attachment"
         </If>
      </FilesMatch>
    </IfModule>
    

    This makes me think that mod_headers didn't load at all. But I have it enabled in httpd.conf:

    ...
    LoadModule filter_module modules/mod_filter.so
    LoadModule headers_module modules/mod_headers.so
    #LoadModule heartbeat_module modules/mod_heartbeat.so
    ...

    Is there any debug log to find out what mods have been loaded and what not?