Disable file execution in the WordPress uploads folder
In this guide, we show you how to disable file execution in the uploads folder for WordPress.
The uploads folder is where your site's images and other media files are stored, which means that it needs to be writable. However, because it is writable, it can be abused by hackers, who can use it to upload and execute malware.
By disabling file execution you don't block the uploading of new files, but the uploaded files won't execute, meaning that hackers can't exploit them.
- Step 1 - Go to the uploads folder in File Manager
- Step 2 - Create a .htaccess file
- Step 3 - Edit the .htaccess file
- Step 4 - Paste in the code and Save
Step 1 - Go to the uploads folder in File Manager
- Log into the one.com Control Panel.
- Open File Manager under Files & Security.
- Navigate to wp-content > uploads within your WordPress installation.
Step 2 - Create a .htaccess file
- Click the arrow, next to the + upload button in the top-left corner.
- Select New other file in the drop-down menu.
- Name the file .htaccess.
Note: If a .htaccess file already exists in the uploads folder, you don't need to create a new one. Simply add the code to the existing file, either at the top or the bottom.
Step 3 - Edit the .htaccess file
- Select the .htaccess file by checking the box in front of it.
- Click Edit in the top menu bar, towards the middle of your screen.
Step 4 - Paste in the code and Save
- Paste in the following code:
# Block executables
<FilesMatch "\.(php|phtml|php3|php4|php5|pl|py|jsp|asp|html|htm|shtml|sh|cgi|suspected)$">
deny from all
</FilesMatch>- Click Save in the top menu bar.
That was all!
Related articles: