Jump to content

Recommended Posts

Posted

This is probably a strange request however i have a directory that is viewable and i want to limit it so that only the actual html pages can be viewed. We have 3 html pages that load but want to mask the directory structure or the ability to view the files in the directory

 

Hopefully im kinda making sense.

 

Das

Posted (edited)

You need to set up Apache to disable directory listing. To do that site wide, add this line to your httpd.conf in the VirtualHost section (if you don't see this, put it in your Directory section):

 

Options -Indexes

 

In the same section, to limit the available file types available to HTML only, add the following:

 

Deny from all

   Order allow,deny
   Allow from all

 

PS: been a long time since I did this so test it before taking my word please!

Edited by LosOjos
Corrected Regex
  • Thanks 1
Posted
Do the HTML pages refer to resources that are stored in the directory you're dealing with? Denying access to those resources will break the pages.
Posted
Do the HTML pages refer to resources that are stored in the directory you're dealing with? Denying access to those resources will break the pages.

 

True - you'd usually explicitly state blocked file types rather than allowing individual types. The above regex can be edited to allow the most common types quite easily if you want to continue whitelisting though, something like:

 

Posted

I think IndexIgnore is probably more flexible in this scenario because it masks rather than denies access to files and folders.

 

If you deny access and then whitelist individual types they will show up in the directory listing, which I believe is contrary to what is desired.

Posted
I think IndexIgnore is probably more flexible in this scenario because it masks rather than denies access to files and folders.

 

If you deny access and then whitelist individual types they will show up in the directory listing, which I believe is contrary to what is desired.

 

Except that the line:

 

Options -Indexes

 

denies directory listing entirely!

 

Don't you just love Apache and it's many methods :)

 

Personally, I think simply turning off directory listing is enough; there hadn't ought to be any files on a web server you don't want accessed via the web, otherwise why are they there?

  • Thanks 1
Posted
Right, I see what you're saying. My responses have been based on the assumption that a directory listing is required, but a listing that shows only files of type HTML.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...