Search code examples
apache.htaccessindexingrootdirectoryindex

What does "Directory Index forbidden by rule" mean?


What could the following line mean?

[Mon Feb 21 20:52:13 2011] [error] [client 66.249.71.150] 
 Directory index forbidden by rule: /var/www/vhosts/website.com/httpdocs/

I have no index.php in the root, since my index is home.php, website root file is defined by .htaccess rules:

My .htaccess file looks like this:

DirectoryIndex index.php /index.php
RewriteCond %{HTTP_HOST} ^website.com$
RewriteRule ^$ en/home [R=301,L]
...

Thanks very much!

update1:

I dont have access to the virtual host config files, im on shared hosting , so only .htacces in my /httpdocs/ thats all I have. What should I do? Should I jus disable DirectoryIndex (I dont use that anyways and the site works fine!) How can I check wether I have directory index or not?

update2:

  • when testing in browser, all seem to work fine, fast and nicely!
  • in log however, i see this:

[Sun Feb 27 02:18:56 2011] [error] [client 66.249.71.81] File does not exist: /var/www/vhosts/website.org/httpdocs/index

Unlike the first error at the top of this page, this seems a regular 404 (my 404 error document is my home page, so error pages show the home)

When I type in 'website.org' the htaccess rule does goed job in redirecting to the default page website.org/en/home and when I type 'websie.org/index' it redirects to website.org/en/home so it all seems to work fine but i dons know what the two error means "Directory index forbidden by rule..."

Clues? Thanks!


Solution

  • EDIT 2: Ok... I think I just completely misread this question at first. You say you don't have an index.php file in the directory? If so, DirectoryIndex index.php /index.php doesn't look correct. Maybe you should try changing that to:

    DirectoryIndex home.php
    

    Am I understanding the issue correctly? You're trying to display the default page for the directory, correct?


    By default, some http.conf setups have the following rule:

    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>
    

    Whenever I set up a vhost, I often change this rule to look more like this:

    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Order deny,allow
        Allow from all
    </Directory>
    

    The important parts in your case are the last two pieces Order and Allow.

    EDIT 1: Actually, after looking into this error a bit more, it's possible that this is even a permissions issue. Can you double-check that Apache has read access to the directory you're trying to access?