mod_rewrite is an Apache module that allows to rewrite requested urls on the fly using rule based rewrite engine. In simple language it is the module that empowers your
.htaccess file. It is not activated by default. So you’ll notice your htaccess rules won’t work on fresh install of Apache. In this tutorial we’ll see how to activate this module.
This tutorials is for the LAMP (Linux) stack. In case you are using WAMP (Windows) then instead please follow this link.
Run below command to enable this module.
sudo a2enmod rewrite
allin your vhost file
In case you are not using any virtual hosts then open
/etc/apache2/apache2.conf in vim (or any of your favourite file editor).
Search for below block of lines.
Options Indexes FollowSymLinks AllowOverride None Require all granted
We need to change
AllowOverride None in above code to
AllowOverride all. So after this modification above block of code looks as below
Options Indexes FollowSymLinks AllowOverride all Require all granted
Just in case you are using virtual hosts then you’ll need to search for above code in
Restart apache server for the changes to take effect.
sudo service apache2 restart
That’s it. Your
.htaccess file rules should now work.