How to activate .htaccess and ModRewrite in Ubuntu 16



.htaccess is disabled by default in Ubuntu 16. ModRewrite could also be disabled. Here are the two steps needed to activate pretty permalink and all the other stuff related to .htaccess.

Activate ModRewrite

 sudo a2enmod rewrite
 sudo service apache2 restart

Edit the Apache main configuration file to activate .htaccess

Open the main configuration file for Apache:

 sudo nano /etc/apache2/apache2.conf

Search for the expression “Options Indexes FollowSymLinks“. Do this by pressing “CTRL + W” and paste the phrase into the Nano search field.
Find the following three lines:

 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted

Change the word “None” to “All”.
The correct version would look like this:

 Options Indexes FollowSymLinks
 AllowOverride All
 Require all granted

Then restart Apache again

 sudo service apache2 restart