How to disallow executable scripts from executing using htaccess
I came across an issue recently in which the client complained that his hosting provider had suspended his website account due to large number of spam emails being sent from this website. The client website was a small 5 page website and CAPTCHA had been implemented on the Contact Us form.
After talking with client’s hosting support I found that the emails were being sent from .php and .pl scripts in the images folder. The images folder had 777 permission meaning that any file could be read, written to and modifiied. I first changed the permissions to 755 and then removed all executable scripts from that folder.
Next I uploaded an .htaccess file to disallow any executable script from running in the images folder. The contents of the .htaccess file are as follows
Order Allow,Deny Deny from all
As can be seen from above the htaccess will now disallow an script or file which does not belong in the images folder. Please see below
Hope the above helped and let me know if you encounter any problems.