How to enable .htaccess on Apache2

An existing .htaccess file will not work with a new/stock install of Apache2 on Linux. The following modifications will need to be made:

  • Edit the /etc/apache2/apache2.conf file and find the section for ‘<Directory /var/www/> then update a line in it from ‘AllowOverride None’ to ‘AllowOverride All’
  • Enable module rewrite by running in the terminal ‘sudo a2enmod rewrite’
  • Restart apache2 with ‘sudo service apache2 restart’
Sidebar