0

So i'm wondering how you professionals go about securing your website by not allowing a user to manually input a url to a certain folder such as website.com/images/ and view a directory listing. The method i've been using is placing an index.php file and using this code, which just brings the user back to main homepage. But i feel like there is probably an easier way to do this. Possibly Server Side?

<?php
ob_start();
/* This will give an error. Note the output
 * above, which is before the header() call */
header('Location: ../index.php');
exit;
?>
Outdated Computer Tech
  • 1,996
  • 4
  • 25
  • 39

1 Answers1

2

Use htaccess to prevent direct access

create .htaccess file add this Options -Indexes line . add it in your project root path

These links may help you 1. deny directory listing with htaccess 2. http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-prevent-htaccess-directory-listing/

Community
  • 1
  • 1
Shafeeque
  • 2,039
  • 2
  • 13
  • 28