Apache error message solution: Forbidden. You don’t have permission to access on this server

Apache error message solution: Forbidden. You don’t have permission to access on this server cover image
  1. Home
  2. Apache
  3. Apache error message solution: Forbidden. You don’t have permission to access on this server

There can be many reasons why the “Forbidden. You don’t have permission to access / on this server” error message is thrown by Apache. The most common cause is when the web server cannot find the index file. As you probably know, the default index file specified in the Apache configuration is index.html. Thus, if this file is missing you would get either the “Forbidden…” error or a listing of the files in the directory.

Let us look at this issue is a little more detail.

The DirectoryIndex line in the Apache configuration file determines which file is used as the index. The line below is generally the default and specifies index.html as the index file.

DirectoryIndex index.html

Sponsored Links

You can set up other files to act as indexes, thus:

DirectoryIndex index.html index.php

But wait, there is more. Another line in the Apache configuration file also has a role to play.

The “Forbidden. You don’t have permission to access / on this server” is shown when Apache is asked to fetch the index file from a directory for which the indexes are “switched off”. Thus,

Options -Indexes

Solution to the “Forbidden…” problem

Dig out the DirectoryIndex line from the Apache configuration file. Make sure it’s not empty and that it specifies one or more index files (as shown above).

Find the Options line in the DocumentRoot section of the Apache configuration file and ensure that is has +Indexes, as in:

Options +Indexes

Editing the .htaccess file

On a web server, you may not have direct access to the Apache configuration file in which case you have to use the .htaccess file.

First login at your web server and check for the .htaccess file. Download it and create a back up. Open this file in Notepad (or any basic editor).

If there is no .htaccess file on the web server, you need to create one to get things working and we will use Notepad for this. Put in the following lines:

DirectoryIndex index.html
Options +Indexes

You can specify other files that can act as the index in the first line. Please put them one after the other separated by a space character. The second line tells Apache that indexes are to be used for the directory.

Lastly, this issue can also be because of permission. Check if access is denied to users in the .htaccess file.

Related articles

Apache Web Development