Stop Showing Index of /directory

Do you get an Index of your website directory files similar to below when something goes wrong? Maybe a spelling mistake / typo or in this case a directory without an index file..

I was having this problem when the website address wasn’t being entered fully. And because I was using .htaccess to force file type I did not have or need a index.html file in this directory.

So trying www.website.co.uk/directory/info/thisfile.html would process the info file and work as required but when mistyping or leaving off info/thisfile.html it would result in displaying the Index of/ directory files. Not really something that you would want revealed.

I tried searching around for a fix and to stop directory browsing and showing my file structure turned out for me to be an easy fix of adding the following code to my .htaccess file:

Options -Indexes

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *