.htaccess not working in Apache2 in Ubuntu

If you put some .htaccess file in your server and doesn’t work as expected, maybe you are trying to install a Drupal site or to set Zend Framework, follow this steps.

Find your site virtual host file or edit the 000-default in the /etc/apache2/sites-enabled/

Add this lines:

<Directory /var/www/mysite/>

AllowOverride all

</Directory>

after this block:

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

Reload the server with sudo /etc/init.d/apache2 reload.
This should be done after each modification.

If you get a 500 type of error trying to view your site don’t panic!

This happens because the rewrite module doesn’t come enabled by default for security reasons.

Create a new file called rewrite.conf in _/etc/apache2/mods-enabled_
in the file put this line “LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so”

Reload one more time the server.
This worked for me and hopefully for you, but I don’t advice this for production servers. This is information for regular Ubuntu users not for a live server where admins should know better.


About this entry