Enable apache mod_rewrite in Ubuntu 14.04 LTS

Ubuntu 14.04 LTS comes with Apache 2.4. This new version introduced different default config filenames and in general some differences. (DocumentRoot /var/www/html)

Activate the mod_rewrite module with

sudo a2enmod rewrite

and restart the apache

sudo service apache2 restart

To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with

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

Below “DocumentRoot /var/www/html” add the following lines:

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

Restart the server again:

sudo service apache2 restart