Cannot enable the use of .htaccess files - No results

August 17, 2014 3.5k views

(Previous issue solved - A new issue has arisen)

1. I create a .htaccess file at var/www/html:

AuthUserFile /etc/htaccess/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user

2. I enable the use of .htaccess files at /etc/apache2/sites-available/default-ssl.conf

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

3. Now, I create an .htaccess file at var/www/html/site:

RewriteEngine On
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/site/index.php [L]

4. So now, a URL that was previously located at can now be accessed via

5. However, all of this set up produces nothing - .htaccess files do not work.

What's wrong here? These the setup shown in point 3 worked on my old host.

4 Answers

I had a similar issue: could not get my .htacess to work properly, despite having the AllowOverride All in the site.conf file, and restarting apache.

I ended up going into apache2.conf and changing there to AllowOverride All, restarted Apache and it started working.

so in /etc/apache2/apache2.conf:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All    << changed that to All
    Require all granted
  • Perhaps I'm very lost - Upon making that change, I get the an Internal Server Error. If I opt to switch it back to AllowOverride None, then I reset the server, the Internal Server Error vanishes.

    Could you possibly let me know exactly what you did? I'm using an Apache installation fresh out of the box.

..just exactly that:

My changes on .htaccess were not taking. It was a wordpress site I was dealing with.
After reading somewhere, I opened /etc/apache2/apache2.conf and changed line 166 to : AllowOverride All

saved, restarted apache and all worked.

Just to be sure I went and checked just now and it all working.

Perhaps suddenly your .htaccess file might be working, but have errors?

  • I really don't know, the frustration is really getting to me.

    If you don't mind, could you possibly share the 'layout' of your .htaccess files and their locations? As in, in which folder you place each file and what they do? I'm assuming that I may be missing something mandatory or putting something in the wrong place.

    Did you not install the mod_rewrite module either? A lot of places say you need that.

sure. I use /var/www as my base and created a new directory in www for each website. So /var/www/ is the root folder for
My .htaccess file is in the root of the web-folder.

Just a thought: have you made sure your .htaccess is readable by www-data
If you created it with your user account, you might want to run:
sudo chown -R www-data:www-data /var/www

and then:
sudo chmod -R 775 /var/www

I looked, and mod_rewrite is installed, so I must have done that at some point.
You can check with:

<?php print_r(apache_get_modules()); ?>


thanks for sharing this, I was breaking my head until found this post!


Have another answer? Share your knowledge.