So I've found many posts here on how to do a similar action, however, I'm still confused. So here is my question. I want to have access to www.mywebsite/folder/index.html but if I were to remove the index.html and just type in www.mywebsite/folder/ I don't want to have access to that. How can I go about doing this? I read that I can use an .htaccess file with deny from all but that restricts me from the whole folder and I can't access the index.html.
Please let me know if there is a solution or another post that I missed that outlines the exact situation.
Thank you!
Which Apache version are you using? In 2.4, you can use DirectoryIndex disabled
to stop it from automatically serving up the index.html, and combine that with Options -Indexes
.
In lower versions disabled
does not exist yet, so using mod_rewrite with a simple RewriteRule that forbids access when the exact folder path (with or without trailing slash) was requested should do it,
RewriteRule ^folder/?$ - [F,L]
To control what error message the user gets to see in each case, specify the ErrorDocument
for the 403 Forbidden status code.