# Fix Apache .htaccess AllowOverride Not Enabled Rewrite Rules Ignored
Your .htaccess file contains perfectly valid rewrite rules, but Apache completely ignores them. No errors in the log, no redirects happening, no rewrites applied. The most common cause is that AllowOverride is set to None in your Apache configuration.
The AllowOverride Directive
AllowOverride controls which directives in .htaccess files Apache processes. When set to None, Apache skips .htaccess files entirely -- they might as well not exist.
Check your current setting:
grep -rn "AllowOverride" /etc/apache2/sites-enabled/
grep -rn "AllowOverride" /etc/apache2/apache2.confYou will likely find:
<Directory /var/www/html>
AllowOverride None
</Directory>Understanding AllowOverride Options
| Value | Allows |
|---|---|
None | All .htaccess directives ignored |
All | All directive types allowed |
AuthConfig | Authentication directives (AuthType, Require) |
FileInfo | Document type control (RewriteRule, AddType, ErrorDocument) |
Indexes | Directory indexing control (Options Indexes) |
Limit | Access control (Allow, Deny, Order) |
Options | Options directive in .htaccess |
For rewrite rules, you need at minimum:
<Directory /var/www/html>
AllowOverride FileInfo
</Directory>For full .htaccess support (rewrites, authentication, custom error pages):
<Directory /var/www/html>
AllowOverride All
</Directory>Enabling mod_rewrite
Even with AllowOverride All, rewrite rules require mod_rewrite to be loaded:
apache2ctl -M | grep rewriteIf it is not listed, enable it:
sudo a2enmod rewrite
sudo systemctl restart apache2On RHEL/CentOS, check /etc/httpd/conf.modules.d/00-base.conf:
LoadModule rewrite_module modules/mod_rewrite.soVerifying .htaccess Is Being Read
Add a deliberate syntax error to your .htaccess:
# .htaccess
InvalidDirectiveHere yesThen request any URL on the site. If you get a 500 Internal Server Error with "Invalid command" in the error log, Apache IS reading the .htaccess file and AllowOverride is working. If you get a normal response (no error), Apache is ignoring the file.
Remove the test line after verifying.
Performance Impact
- 1.Every request that passes through a directory with
AllowOverride Allcauses Apache to: - 2.Check for
.htaccessin the current directory - 3.Check parent directories recursively up to the document root
- 4.Parse and apply any
.htaccessfiles found
On high-traffic sites, this adds measurable overhead. The recommended approach for production is to move .htaccess directives into the main Apache configuration:
```apache # Instead of .htaccess, put rules directly in VirtualHost <VirtualHost *:80> DocumentRoot /var/www/html
<Directory /var/www/html> Require all granted
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php [QSA,L] </Directory> </VirtualHost> ```
Then set AllowOverride None to eliminate the filesystem lookup overhead on every request.
Common Framework Requirements
Popular PHP frameworks require AllowOverride All for their .htaccess-based URL rewriting:
- WordPress: Requires rewrite rules in
.htaccessfor pretty permalinks - Laravel: Routes all requests through
public/index.php - Symfony: Similar to Laravel, routes through
public/index.php - Drupal: Clean URLs depend on
.htaccessrewrite rules
If you migrate a site and forget to set AllowOverride All, all URLs except the homepage return 404 errors.
Testing After Fixing
```bash sudo apachectl configtest sudo systemctl reload apache2
# Test with a URL that should be rewritten curl -sI https://example.com/nonexistent-page | grep "HTTP/" # If Laravel/Symfony, should return 404 from the application, not Apache ```