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

bash
grep -rn "AllowOverride" /etc/apache2/sites-enabled/
grep -rn "AllowOverride" /etc/apache2/apache2.conf

You will likely find:

apache
<Directory /var/www/html>
    AllowOverride None
</Directory>

Understanding AllowOverride Options

ValueAllows
NoneAll .htaccess directives ignored
AllAll directive types allowed
AuthConfigAuthentication directives (AuthType, Require)
FileInfoDocument type control (RewriteRule, AddType, ErrorDocument)
IndexesDirectory indexing control (Options Indexes)
LimitAccess control (Allow, Deny, Order)
OptionsOptions directive in .htaccess

For rewrite rules, you need at minimum:

apache
<Directory /var/www/html>
    AllowOverride FileInfo
</Directory>

For full .htaccess support (rewrites, authentication, custom error pages):

apache
<Directory /var/www/html>
    AllowOverride All
</Directory>

Enabling mod_rewrite

Even with AllowOverride All, rewrite rules require mod_rewrite to be loaded:

bash
apache2ctl -M | grep rewrite

If it is not listed, enable it:

bash
sudo a2enmod rewrite
sudo systemctl restart apache2

On RHEL/CentOS, check /etc/httpd/conf.modules.d/00-base.conf:

apache
LoadModule rewrite_module modules/mod_rewrite.so

Verifying .htaccess Is Being Read

Add a deliberate syntax error to your .htaccess:

apache
# .htaccess
InvalidDirectiveHere yes

Then 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. 1.Every request that passes through a directory with AllowOverride All causes Apache to:
  2. 2.Check for .htaccess in the current directory
  3. 3.Check parent directories recursively up to the document root
  4. 4.Parse and apply any .htaccess files 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 .htaccess for pretty permalinks
  • Laravel: Routes all requests through public/index.php
  • Symfony: Similar to Laravel, routes through public/index.php
  • Drupal: Clean URLs depend on .htaccess rewrite 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 ```