Is your .htaccess file not working and you find it difficult to figure out what’s the issue. Before using .htaccess file you need to enable it.
What’s the use of .htaccess File
.htaccess is Apache’s directory-level configuration file. Using htaccess file you can set directory level configuration without making any changes in httpd.conf file.
My previous posts on .htaccess.
How to Enable .htaccess File in Apache2
You can edit the server settings to allow the .htaccess file to override standard website configs.
NOTE –Settings are override for only those directories where .htaccess file is placed.
In apache configuration file AllowOverride directive controls whether .htaccess file is allowed or not.
AllowOverride All It means .htaccess file is allowed. And every time your application starts, Apache reads and apply the directives written in .htaccess file.
AllowOverride None It means ignore .htaccess file.
To edit the settings Open the apache2 default host configuration file and change AllowOverride None to AllowOverride All.
sudo vim /etc/apache/sites-available/default
Options Indexes FollowSymLinks MultiViews
allow from all
After you done the changes, restart apache.
sudo service apache2 restart
sudo /etc/init.d/apache2 restart