How to deny php execution in specific folders and with specific file names

May you site have been hacked and you want to don’t allow execution of specific files with specific names.

May you have give upload access to a folder and you want in this folder php files cannot been executed.

You can do this with .htaccess file

Examples below

#With this htaccess snippet you can disallow all php files execution
<Files *.php>
  deny from all
</Files>
#With this htaccess snippet you can disallow php files execution with name myphpfile.php
<Files *myphpfile.php>
  deny from all
</Files>
#With this htaccess snippet you can disallow php files execution that exists in wp-content/uploads folder
<Files *wp-content/uploads/*.php>
  deny from all
</Files>

Comments