: .htaccess: DirectoryIndex and 403 forbidden 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
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?
More posts by @Ann8826881
2 Comments
Sorted by latest first Latest Oldest Best
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.
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.