How to enable .htaccess in apache

Step 1.

cd /etc/apache2/sites-available

Step 2.

vim default (or default-css)

Step 3. Change AllowOverride from ‘None’ to ‘All’

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All    <---- replace None with All
    </Directory>
    <Directory /var/www >
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All   <---  replace None with All
            Order allow,deny
            allow from all
    </Directory>

Step 4. Enable Mod Rewrite

sudo a2enmod rewrite

5. Restart Apache

service apache2 restart

You are now done…

Sample .htaccess…

(more…)

Continue Reading
Close Menu