dastrix Posted September 8, 2015 Posted September 8, 2015 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
ijk Posted September 8, 2015 Posted September 8, 2015 You have a directory containing multiple file types and have allowed directory listing for that directory. However, you wish to restrict the list of files to those of type html? https://wiki.apache.org/httpd/DirectoryListings - see Excluding Files, which links to mod_autoindex - Apache HTTP Server Version 2.5 Hope that helps. 1
LosOjos Posted September 8, 2015 Posted September 8, 2015 (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 September 8, 2015 by LosOjos Corrected Regex 1
ijk Posted September 8, 2015 Posted September 8, 2015 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.
LosOjos Posted September 9, 2015 Posted September 9, 2015 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:
ijk Posted September 9, 2015 Posted September 9, 2015 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.
LosOjos Posted September 10, 2015 Posted September 10, 2015 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? 1
ijk Posted September 10, 2015 Posted September 10, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now