Request a Quote

Block directory browsing in PHP

Block directory browsing in PHP

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:

[sourcecode language=”plain”]Options Indexes FollowSymLinks[/sourcecode]

To:

[sourcecode language=”plain”]Options FollowSymLinks[/sourcecode]

Update .htaccess file:

Add below line:

[sourcecode language=”plain”]Options -Indexes[/sourcecode]

That’s all, You are done :)

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2015 Trimantra Software Solution LLP- Software Outsourcing Company India. All rights reserved.