Ubuntu server - Enabling .htaccess file to rewrite path

13/10/2023 14:57

As of Ubuntu 14.04 (and Apache 2.4), the default DocumentRoot was changed from /var/www to /var/www/html.

Firstly enable a2enmod and restart Apache.

sudo a2enmod rewrite 

Then edit the 000-default.conf file

sudo nano /etc/apache2/sites-enabled/000-default.conf

and add these lines at the end

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

Finally, restart Apache for the configuration to take effect.

sudo service apache2 restart