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

**Code:** `.htaccess: Invalid command (500 Internal Server Error)` · **Category:** Nginx / Apache · **Seen on:** Apache, PHP, Linux

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/nginx-apache/apache-htaccess-invalid-command)
