Monday 25 May 2015

Block directory browsing in PHP


It is very important part for any web application. At one side, when we are taking care a lot to prevent our code to be copied, why we forget to implement Directory Browsing. At least you can save your client side scripts and images. By implementing this mechanism your application will deny to display js, jquery, stylesheet, image directories or even any directory of application.

Best thing about this mechanism is it’s implementation, it is very easy. Just one line of code, need to be changed or written. It is worth to write.

As much as I know, there are 2 ways you can implement this.


  1.     Update apache server configuration file i.e. httpd.conf
  2.     Update application’s .htaccess file

Update httpd.conf file:
Replace:
Options Indexes  FollowSymLinks
To:
Options FollowSymLinks
Update .htaccess file:
Add below line:
Options -Indexes

That’s all, You are done :)

As much as I know, there are 2 ways you can implement this.
  1. Update apache server configuration file i.e. httpd.conf
  2. Update application’s .htaccess file

Update httpd.conf file:

Replace:
1
Options Indexes  FollowSymLinks
To:
1
Options FollowSymLinks

Update .htaccess file:

Add below line:
1
Options -Indexes
That’s all, You are done :)
- See more at: http://blog.trimantra.com/block-directory-browsing-in-php/#sthash.NSIR9Cra.dpuf