Disable Code Execution for WordPress Uploads directory

One of the important step that you can take for security of your wordpress blog is disabling code execution from WordPress Uploads directory.

This can be done by creating an .htaccess file as shown below and putting it in uploads “wp-content/uploads/” folder of your wordpress installation. This will prevent any PHP code in your uploads directory from executing.

This is an added level of protection against a hacker managing to upload PHP code into your “uploads” directory. Even if they manage to do that, the code won’t execute if you have this option enabled. The contents of the .htaccess file are below:

You can achieve this by yourself as described above or use WordPress Plugin like Wordfence to do it. It is available in Wordfence General Settings Section as shown below.