I am learning .htaccess directives.

To test, I create a new .htaccess file under my Joomla website and a test.html file. Then I put

DirectoryIndex test.html

in the .htaccess file. However, I am getting a 403 forbidden error. Why is this?

  • What URL are you requesting? Where is test.html? Where is .htaccess located? Do you have any other .htaccess files along the file path? – MrWhite Jul 6 '16 at 14:10

The only way to be sure why you are receiving a 403 error is to check the logs. They will tell you the reason why it is forbidden.

The DirectoryIndex itself doesn't create any new rule that would provide a 403 error. However, if the error began after you made that change, you likely have Options -Indexes, or a similar line, which gives a 403 message rather than displaying an empty directory. If that is the case, you may not actually have a file named test.html in that document root. Try changing the DirectoryIndex back, visit that directory, maybe rename any other files that might be directory index files until you see the directory listing. See if you find test.html in the directory listing. If not, simply move that file there and change then implement the DirectoryIndex line.


DirectoryIndex test.html is not ordinarily done in .htaccess.

In order for it to work in .htaccess, you will need AllowOverride All (or something similar) within your sites .conf file.

Ordinarily, DirectoryIndex test.html is placed in the sites .conf file. This is the best place for this directive.

Where you find your .conf files all depends upon your install. You can find your configuration file either as /etc/apache2/httpd.conf or as /etc/apache2/sites-available/domainname.tld.conf.

If you are on a shared host, you may not have access to your .conf file and will need your host to help you with this. This is a safe change and they should do this without an issue.

It is recommended that you include safeguards such as index.html, index.htm, index.php, etc., along with your test.html. If you use test.html and your test.html does not exist, you will receive a 403 error if the Options -Indexes directive exists. I do not recommend changing the Options directive to allow indexing. This is a security issue. This is the reason for the safeguard. Always make sure that each directory has at least one of your DirectoryIndex files within them to avoid errors.


Check if your chosen index file (test.html) has the correct permission.

I had the same problem when I uploaded my website files in zip format and then extracted using cPanel. By default, cPanel gave the wrong file permissions (I can't remember what exactly).

To solve the problem, I just changed my file and folder permissions to provide read access to Group and World users. Note that I used DirectoryIndex in htaccess, same as your setup.

For the permissions, I use:

644 - files    
755 - folder

Based from:


For the commands:

find . -type f -exec chmod 644 {} +
find . -type d -exec chmod 755 {} +

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.