How to Activate an .htaccess file

Posted August 23, 2018 11.3k views
ApacheUbuntu 16.04

Hi, i tried to enable the htaccess according with this cloud support link even, i followed this suggestion for any other who posted the same question time ago.

within this path /etc/apache2/sites-available/ I found these files

  • 000-default.conf
  • default-ssl.conf

I added the following block inside the first file

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

But after restart the apache and check I receive this error message on my browser.

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.18 (Ubuntu) Server at Port 80

So, please I beg your support to fix this problem because I’m required to enable htacess for my enterprise.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hello friend!

Check /etc/apache2/apache2.conf and see if one of those “Directory” settings exists like the one you put in your virtual host, it may be possible that one is overriding it there, and that you can just change it to “AllowOverride All” as well.

Kind Regards,

  • HI Jarland, efectively, that is the right path /etc/apache2/apache2.conf and I execute the below commands and then, .htaccess activation was made successful.

    root@naboo-ubuntu-512mb-nyc3-01:/etc/apache2# sudo a2enmoderewrite

    Enabling module rewrite.
    To activate the new configuration, you need to run:
    service apache2 restart

    root@naboo-ubuntu-512mb-nyc3-01:~# sudo nano /etc/apache2/apache2.conf

    Within apache2.conf I replaced none by All in AllowOverride with <Directory> tag and also within <FilesMatch> tag I replaced denied by granted, saved the changes.

    <Directoy /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All (none)
    Require all granted

    <FilesMatch “^.ht”>
    Require all granted (denied)
    </FilesMatch >

    And finally, execute this command

    root@naboo-ubuntu-512mb-nyc3-01:/etc/apache2# sudo service apache2 restart

It sounds like your .htaccess file might indeed be enabled, but that you have an error in your .htaccess file.

Try commenting out everything in your .htaccess file, and see if you still get the error. If you don’t get an error, then uncomment each item one set at a time until you find the error.

Wayne Sallee