Menu Close

How to Prevent Access to Your php includes files by htaccess file ?

If you are running php websites, and a php includes folder that is only used for the calling of your own php scripts. I know you do not want browsers to access your includes folder. You can do it by htaccess file using Mod_Write.

## Enable Mod Rewrite, this is only required once in each .htaccess file
RewriteEngine On 
RewriteBase / 
## Test for access to includes directory
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /includes/ .*$ [NC] 
## Test that file requested has php extension 
RewriteCond %{REQUEST_FILENAME} ^.+\.php$ 
## Forbid Access 
RewriteRule .* - [F,NS,L]

Where /includes/ is your includes directory. All browsers to your includes folder are forbidden.

 

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

See also  Adding MIME Types by .htaccess file
  • You must be logged in to reply to this topic.