Enable .htaccess in Apache2

At first You should define,  mod_rewrite is a part of Apache server that can rewrite requested urls on the fly.

To enable in Ubuntu, you just need to write this command in terminal

sudo a2enmod rewrite

Then edit /etc/apache2/sites-available/default

Find the following

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

and change it to

Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

and finally restart Apache

/etc/init.d/apache2 restart

To enable in windows, open the httpd.conf file. This file is found in the apacheconf directory

Locate the following line of code:
#LoadModule rewrite_module modules/mod_rewrite.so

Remove the # from the line as seen below to enable the module:
LoadModule rewrite_module modules/mod_rewrite.so

Under “<directory XXX></directory>” section:
Change the line “AllowOverride None” to “AllowOverride All“.

Save the httpd.conf file

Restart your Apache Server

After enabling mod_rewrite you can write .htaccess file for your web application.

Permanent link to this article: https://blog.openshell.in/2010/12/enable-htaccess-in-apache2/

Leave a Reply

Your email address will not be published.