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.


Related Posts

Leave a Reply