Guides › HTML / PHP sites › Site down or error screens

Apache Error: Invalid Command in .htaccess (Module Not Enabled)

Modules.

Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
Site down or error page

Invalid command in .htaccess means the file uses a directive from an Apache module that is not loaded on your server. The site returns a 500 error until the line is wrapped or removed.

1Read the log2Match the directive to its module3Wrap it in IfModule4Enable the module5Check spelling6Remove what you do not need7RetestFixed? Test the site. If not, get help.
The steps in order. Work down the list and stop when the problem is solved.

Step 1: Read the log

Illustration for Step 1: Read the log

It says for example Invalid command 'ExpiresActive', perhaps misspelled or defined by a module not included in the server configuration. The quoted word is the directive.

Step 2: Match the directive to its module

Illustration for Step 2: Match the directive to its module

ExpiresActive needs mod_expires, RewriteRule needs mod_rewrite, Header needs mod_headers, AddOutputFilterByType needs mod_filter.

Step 3: Wrap it in IfModule

Illustration for Step 3: Wrap it in IfModule

Place the lines inside <IfModule mod_expires.c> and </IfModule>. If the module is missing, Apache skips the block instead of failing.

Step 4: Enable the module

Illustration for Step 4: Enable the module

On your own server run a2enmod expires (use the matching name) and systemctl restart apache2. On shared hosting ask support to enable it.

Step 5: Check spelling

Illustration for Step 5: Check spelling

A misspelled directive gives exactly the same error.

Step 6: Remove what you do not need

Illustration for Step 6: Remove what you do not need

Delete rules copied from a tutorial that you do not use.

Step 7: Retest

Illustration for Step 7: Retest

Reload the site and check the log.

Still stuck?

If these steps do not solve it, we fix it for you for a flat $99. Full refund if we do not solve it within 7 days.

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-22.