Enable mod rewrite module on Apache 2.4

Date Posted:01-04-2017

Mod rewrite is an essential module for .htaccess rules to work on apache server. Follow the below post incase apache is not installed on host.

Install Apache 2.4 on Ubuntu


Login to the server as root.

Execute the below command to enable the mod_rewrite module.

a2enmod rewrite

Restart apache service to make the effect.

service apache2 restart

If you followed the above post, there will be a default configuration 000-default.conf. Open the file and add the following content.

vi /etc/apache2/sites-enabled/000-default.conf

<Directory /var/www/html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

If the documentroot is different other than /var/www/html then replace it with appropriate directory.

Restart apache service for the changes comes into effect.

service apache2 restart


1. Execute the below command and look for rewrite module in the output.

apachectl -M|grep rewrite

2. Create a .htaccess on the directory and add simple rewrite rule.

vi /var/www/html/.htaccess

RewriteEngine on

Access the domain or IP address (http://IPAddress) on the browser. If you see 500 internal error then there is a problem with rewrite module.

Look for any error while accessing the page on browser using below command. If you see any error related Rewrite  then there is a problem with rewrite module.

tail -fn0 /var/log/apache2/error_log

Incase of any issue then please comment here.

Leave a Reply