How to use htaccess to protect your config files

Marc0

Well-known member
Registered
Joined
Jun 6, 2012
Messages
890
Points
28
To stop anyone exploit/view your config files from your service by some tools, we can use .htaccess to protect our files by using code:

# to protect config_file.php
Code:
<Files config_file.php>
order allow,deny
deny from all
</Files>
# to protect wordpress config file
Code:
<Files wp-config.php>
order allow,deny
deny from all
</Files>
# to protect the .htaccess file itself:
Code:
<Files .htaccess>
order deny,allow
deny from all
</Files>
If you Chmod for a folder is 0777 to upload thumnails so using this code to protect scripts run from its folder and sub-folders
Code:
RewriteEngine On
RewriteRule .(php|php3|php4|php5|phps|phtml|shtm|shtml|cgi|pl |pm|asp|cfm|jse|jsp|jar|py|exe|com|bat|dll|pif|scr |reg|inf|htaccess|txt|html|htm)$ - [F]
Hope it's useful to people want to protect your files online.
 

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top