.htaccess: Invalid command (500 Internal Server Error) Nginx / Apache Origin: Edge & web server Last updated 5 Nov 2026

Apache: [core:alert] /var/www/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

A .htaccess file uses a directive the server can't handle, causing 500 errors for the whole directory.

Exact message you may see .htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration[core:alert] .htaccess: Invalid command.htaccess: Invalid command 'RewriteEngine'.htaccess: Invalid command 'ExpiresActive'500 Internal Server Error .htaccess Invalid command
Seen on: Apache PHP Linux

Meaning

Common: php_value/php_flag under PHP-FPM/CGI (use .user.ini instead), RewriteEngine without mod_rewrite, Header without mod_headers, or Require syntax from Apache 2.2 vs 2.4. Enable the module, wrap in <IfModule>, or remove incompatible directives. Check the Apache error log for the exact line.

Common causes

  • php_value with PHP-FPM/FastCGI
  • mod_rewrite/mod_headers/mod_expires not enabled
  • Apache 2.2 Order allow,deny on 2.4
  • AllowOverride None ignoring or blocking directives
  • Typos

⚡ Quick fix

  1. sudo a2enmod rewrite headers expires and restart
  2. Replace php_value with .user.ini for FPM
  3. Wrap optional directives in <IfModule mod_headers.c>

Detailed fix by platform

Linux

  1. sudo tail -20 /var/log/apache2/error.log

How to diagnose

  1. Directive — Named in error log?
  2. Module — Enabled?
  3. PHP — mod_php or FPM?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Edge & web server. Errors that are often confused with or caused by this one (click to open):

AH00015: Unable to open logs — Apache: AH00091: apache2: could not open error log file /var/log/apache2/error.log. AH00015: Unable to open logs (Permission denied) (Nginx / Apache)AH00015: Unable to op…AH00037: Symbolic link not allowed or link target not accessible — Apache: [core:error] AH00037: Symbolic link not allowed or link target not accessible: /var/www/html/current (Nginx / Apache)AH00037: Symbolic lin…AH00072: make_sock: could not bind to address 0.0.0.0:80 — Apache: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 / AH00015: Unable to open logs (Nginx / Apache)AH00072: make_sock: c…AH00124: Request exceeded the limit of 10 internal redirects — Apache: AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary (Nginx / Apache)AH00124: Request exce…AH00526: Syntax error on line of apache config — Apache: AH00526: Syntax error on line 12 of /etc/apache2/sites-enabled/site.conf: Invalid command 'Foo', perhaps misspelled or defined by a module not included in the server configuration (Nginx / Apache)AH00526: Syntax error…AH00558 — Apache: AH00558: apache2: Could not reliably determine the server's fully qualified domain name (Nginx / Apache)AH00558AH01630: client denied by server configuration — Apache: [authz_core:error] AH01630: client denied by server configuration: /var/www/html/ (Nginx / Apache)AH01630: client denie….htaccess…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.