VDS Sphera Knowledge Base

Main / Browse Categories / Apache / Why does my site show a Directory Listing or Forbidden error instead of the web site?

Print article Print Article    Email article Email Article

Why does my site show a Directory Listing or Forbidden error instead of the web site?

When someone goes to your site using only the domain name and not specifying a specific page, Apache looks for an index file to use.  If Apache can't find the index file (e.g. index.html, index.htm, index.php, etc.),  it attempts to show a directory listing instead.  If directory listings are disabled, it will return a forbidden error.

There are a couple possibilities as to why Apache didn't find the index file:

1. This can happen if the index file has been deleted or renamed.

2. An .htaccess file has been created and contains a line using the DirectoryIndex directive that is missing the index file's name and extension OR has the filenames in the wrong order.

For example: Say, in the web directory (/var/www/html) the index file is named "index.htm".  The web directory also has the file ".htaccess"   And, say this file contains the line  

DirectoryIndex index.html index.php

This line limits the list of index files that Apache will look for.  And, since the file we need, "index.htm", is not listed, Apache will not return it but will instead think there is no mathcing file and then attempt the directory listing - even though the index.htm file is there the whole time. 

So, the fix would be to add the name to the directive line in .htaccess like this:

DirectoryIndex index.html index.php index.htm

But, say the web directory contains both the index.htm (that you want to use) and another file index.html (that you dont want to use).  Using the directive as shown above, Apache would actually return the wrong file (index.html) because Apache reads the list from left to right.

So, the best solution for this example looks like this:  

DirectoryIndex index.htm index.html index.php

User Comments
Why does my site show a Directory Listing or Forbidden error instead of the web site?  
There are no user comments for this topic.
 

Attachments
No attachments.

Related Articles
 Where is the Apache httpd.conf file located?
 How do I restart Apache?
 How can I create a Script Alias in Apache to Neomail?
 How can I prevent Directory Listing?
 How do I prevent hot linking of my pictures, movies, or other files?

Why Choose Our Hosting?

  • Unmatched Customer Support!
  • Virtual Private Server technology provides a rich, dedicated-like environment for every account.
  • We are known for our superb quality, performance and flexible hosting environment. We manage the server, software, and network you do the rest.
Continue reading »

Featured Hosting Plan


Learn more about our VPS Extreme

What is Included?

  • PHP 5/MySQL 5
  • Parallels® Plesk Panel 10
  • Unique IP Address
  • Daily VPS Backups (Off Server)
  • SAS Hardware Raid diskspace
  • CentOS 5 x86_64 bit
  • Multi-homed Tier 1 Bandwidth
  • Full Upgrade capabilities
Continue reading »