The difference between apache modules with and without the “.c” extension

apache-2.4

I am running apache v2.4 on Ubuntu 14.04 and have containers/directives this format

<IfModule mpm_prefork_module>
        # ...
</IfModule>

However I often see modules referenced in apache official documentation and in stackexchange sites this way:

<IfModule prefork.c>
        # ...
</IfModule>

Ive searched alot, including herehttp://httpd.apache.org/docs/2.4/mod/core.html#ifmodule and Im unable to find what the difference is and when one is supposed to be used over the other?


Take the rewrite module for example

From the apache documentation: ifmodule directive

The module argument can be either the module identifier or the file
name of the module, at the time it was compiled.
For example,
rewrite_module is the identifier and mod_rewrite.c is the file name.

And its very common to see this in .htaccess files

<IfModule mod_rewrite.c>
    # ....
</IfModule>

Ive grep'ed my /etc/apache2 directory and "mod_rewrite.c" isn't defined anywhere.

On my machine the file /etc/apache2/mods-available/rewrite.load
contains:

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

so is mod_rewrite.c a reference to a windows/other file? in which case referring to it on a linux machine would be incorrect syntax?

Best Answer

In the page you linked to, it contains this text:

The module argument can be either the module identifier or the file name of the module, at the time it was compiled. For example, rewrite_module is the identifier and mod_rewrite.c is the file name. If a module consists of several source files, use the name of the file containing the string STANDARD20_MODULE_STUFF.

Using the example provided, the rewrite module can either be referred to as 'rewrite_module' (identifier) or mod_rewrite.c (filename). Both are equivalent, and there is no difference. You can use either.

The module with the source file mod_rewrite.c, gets compiled into mod_rewrite.so, which is what you'll have on your filesystem. This source file has the line 'module AP_MODULE_DECLARE_DATA rewrite_module;' in it, which declares a module called 'rewrite_module'.

The module can be referred to either as 'rewrite_module', which is the identifier, or 'mod_rewrite.c', which is the source file it was compiled from.

The 'LoadModule' line tells it to load the module with the identifier 'rewrite_module' from the already-compiled object mod_rewrite.so. When you configure this, you can either refer to the identifier or the source file name if you know it.

Related Topic