How to Activate an .htaccess file

August 23, 2018 3.2k views
Apache Ubuntu 16.04

Hi, i tried to enable the htaccess according with this cloud support link https://cloudsupport.digitalocean.com/s/ 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
</Directory>

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 104.236.107.170 Port 80

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

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,
Jarland

  • 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
    </Directory>

    <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
Wayne@WayneSallee.com

Have another answer? Share your knowledge.