Thursday, March 6, 2014

Dont Forget .htaccess

How to read a file .htaccess over apache

If your RootDirectory is
/var/www directory.

use to active
$ sudo a2enmod rewrite
command and that should work, right?


Well, not really… Even though the issued command creates the symlink for the rewrite.load file at /etc/apache2/mods-enabled, you still have to manually edit your /etc/apache2/sites-enabled/000-default file and change the AllowOverride directive from None to All at the /var/www Directory section.

So the section that looks like:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None # change this line
    Order allow,deny
    allow from all
</Directory>
Should look like:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All # now it will read .htaccess
    Order allow,deny
    allow from all
</Directory>

Restart the service
service apache2 restart.
With AllowOverride directive to All , you are tell' the WebServer to read .htaccess  and load. Otherwise it wont read (AllowOverride None).


No comments:

Post a Comment