How to enable .htaccess in Apache HTTP server


A .htaccess file is a directory-level configuration file for Apache HTTP server, which allows one to override the web server’s system-wide settings without modifying the global configuration file (e.g., httpd.conf or apache2.conf). Things like per-directory access control, password protection, URL redirection or hotlink prevention can be configured in the .htaccess file.

You should avoid using file.htaccess completely if you have access to httpd main server config file. Using file.htaccess slows down your Apache HTTP server. Any directive that you can include in a .htaccess file is better to set in a Directory block, as it will have the same effect with better performance.

Details about .htaccess can be found here.


By default, .htaccess isn’t available. To enable it you will need to edit the configuration file.

Edit file  /etc/apache2/sites-available/ 
looks something like this:

#  /etc/apache2/sites-available/
<VirtualHost *:80>
    DocumentRoot /var/www/html/arso
    <Directory /var/www/html/arso>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all 

add or change line 8 to AllowOverride All and if you have mod_rewrite loaded that’s all. 

Rewrite module

To enable rewrite module, run:

sudo a2enmod rewrite
sudo service apache2 reload

Leave a Comment

Your email address will not be published. Required fields are marked *