OM2 Posted September 22, 2009 Share Posted September 22, 2009 Can someone tell me how I can stop someone from seeing the contents of a directory if it doesn't have an index file? I've got Linux hosting and currently, if the directory doesn't have index.html or similar, then you can see all the files names What methods are there to stop all such viewing? (I wasn't sure if this was a PHP question or not, but I thought I'd try asking anyway) Thanks OM Quote Link to comment https://forums.phpfreaks.com/topic/175128-how-do-i-stop-people-seeing-contents-of-directories-if-no-index-file-exists/ Share on other sites More sharing options...
JonnoTheDev Posted September 22, 2009 Share Posted September 22, 2009 Add to an htaccess file Options +Indexes Quote Link to comment https://forums.phpfreaks.com/topic/175128-how-do-i-stop-people-seeing-contents-of-directories-if-no-index-file-exists/#findComment-922981 Share on other sites More sharing options...
OM2 Posted September 22, 2009 Author Share Posted September 22, 2009 Add to an htaccess file Options +Indexes i read up and that shows everything in a directory! i think this is the right answer: Options -Indexes BUT: how do i make it so that the same rule applies to all sub directories? (without necessarily making a global setting for the whole server) thanks Quote Link to comment https://forums.phpfreaks.com/topic/175128-how-do-i-stop-people-seeing-contents-of-directories-if-no-index-file-exists/#findComment-923038 Share on other sites More sharing options...
JonnoTheDev Posted September 22, 2009 Share Posted September 22, 2009 Place in the document root Quote Link to comment https://forums.phpfreaks.com/topic/175128-how-do-i-stop-people-seeing-contents-of-directories-if-no-index-file-exists/#findComment-923129 Share on other sites More sharing options...
Psycho Posted September 22, 2009 Share Posted September 22, 2009 Place in the document root I think he means do not place the folder in the docoument root of the site. Then the folder is not accessible at all via the web, but you can still access the documents via your PHP code. Quote Link to comment https://forums.phpfreaks.com/topic/175128-how-do-i-stop-people-seeing-contents-of-directories-if-no-index-file-exists/#findComment-923131 Share on other sites More sharing options...
PFMaBiSmAd Posted September 22, 2009 Share Posted September 22, 2009 Options -Indexes only prevents directory listing. It does not prevent serving web pages. Quote Link to comment https://forums.phpfreaks.com/topic/175128-how-do-i-stop-people-seeing-contents-of-directories-if-no-index-file-exists/#findComment-923137 Share on other sites More sharing options...
dreamwest Posted September 23, 2009 Share Posted September 23, 2009 if you have Options - Indexes in your root htacess, and you have something like this http://site.com/ http://site.com/dir/secret_file.flv http://site.com/dir/even_more_secret.txt http://site.com/dir/super_secret.php Someone going to : http://site.com/dir/ will get a forbidden, and your files wont be displayed to the browser Quote Link to comment https://forums.phpfreaks.com/topic/175128-how-do-i-stop-people-seeing-contents-of-directories-if-no-index-file-exists/#findComment-923332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.