VDS Sphera Knowledge Base
| Main / Browse Categories / Apache / 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
|
||||||||
| No attachments. |


