Apache2 .htaccess RewriteEngine error

To enable .htaccess files on your server, edit “/etc/apache2/sites-available/default” file, change AllowOverride to All

NameVirtualHost *
<VirtualHost *>
        ServerAdmin admin@site.com

        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                #RedirectMatch ^/$ /apache2-default/
        </Directory>

Then restart apache by doing “/etc/init.d/apache2 restart to restart apache”

Try to see if everything is working fine, if not, check your apache logs in /var/log/apache2, if you have the following error “/var/www/.htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration”

simply do “sudo a2enmod rewrite” and restart apache again and all should work fine!

This entry was posted in Apache, Help, Hosting, linux, PHP, Programming, Tutorials, Web and tagged . Bookmark the permalink.

2 Responses to Apache2 .htaccess RewriteEngine error

  1. jon says:

    you’re a life saver…thank you so much for posting this.

  2. Aksel says:

    Thanks!!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>