Apache Rewrite

By default Apache rewrite should be enabled. If its not enabled, we can enable it manually with the following command:

a2enmod rewrite
Module rewrite already enabled

If you have your .htaccess already but the file isn’t behaving as intended, it maybe because we haven’t set up Apache correctly. We need to enable AllowOverride all from AllowOverride None.

/etc/apache2/apache2.conf

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

It will now become:

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

There is another module under Apache called expires which helps with website peformance.