Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 426

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/templates/ja_purity/ja_templatetools.php on line 49
How To Use .htaccess to Prevent Apache HTTPD Directory Listing - The Scripts Library Community

Free Programming Tutorials & Source Code

 
  • Increase font size
  • Default font size
  • Decrease font size
Home PHP How To Use .htaccess to Prevent Apache HTTPD Directory Listing

How To Use .htaccess to Prevent Apache HTTPD Directory Listing

(0 votes, average: 0 out of 5)

 

Apache HTTPD servers are configured by default to display directory listing, when index files like index.htm or index.html of index.php etc. are not present in the directory. This can expose sensitive information to prying eyes and are often indexed by search engines. This can compromise your data by making it visible to unintended audience. The solution is simple. You can add a line to your .htaccess file (create the file if not present) to prevent directory listing for that directory and its sub-directories:
IndexIgnore *

The * matches all files in the directory. You can also restrict only a subset of file from being displayed. For example if you would want the directory content to be listed but not include the images in the listings then you should use this command:
IndexIgnore *.png *.gif *.jpg

This would return a list of all files not ending in .png, .jpg or .gif, but would still list .txt, .html, etc.

On the other hand if your server is setup to prevent directory listing, but you want to list the directories by default, then add the following in your .htaccess file:
Options +Indexes