Why is Apache ignoring my .htaccess file?

Last updated on | 2 replies

You will find that .htaccess will be ignored by default in Apache. We can enable it by altering the configuration file.

Firstly, backup the configuration file.

sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak

Open the config file.

sudo nano /etc/apache2/apache2.conf

Scroll down the the following section.

/etc/apache2/apache2.con
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

AllowOverride None means that .htaccess will be ignored. Change it to AllowOverride All.

/etc/apache2/apache2.con
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Save and exit (press CTRL + X, press Y and then press ENTER)

Restart Apache.

sudo systemctl restart apache2

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

2 replies

Leave a reply

Your email address will not be published. Required fields are marked *

  1. For me, I needed to add this to the apache host conf file. I’m using windows so it may be different between operating systems.