Enabling .htaccess file to rewrite path (not working)

For apache version 2.4 and later, you have to go to

/etc/apache2/apache2.conf

You have to edit that file (you should have root permission). Change directory text like this;

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Now restart apache.

service apache2 restart

Hope it works.


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

If you don't want to repeat the same configurtion at each upgrade / update

The best way is :

Edit or create a config file

/etc/apache2/conf-available/httpd.conf

Add

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>

Enable the config file

sudo a2enconf httpd

Restart or reload Apache

sudo service apache2 restart

or

sudo service apache2 reload

It's done!