How to protect PHP file execution in a specific directory?

Having some directories writeable by default makes your site vulnerable to hacker attacks. Hackers can use the function to upload backdoor access files or malware to your website. It is of vital importance that you understand what you are doing before you go on to disable any PHP execution. Doing that will make sure that any PHP file will not run in those particular directories. 
However, if you need to disable PHP execution for a particular directory, you will need to create the .htaccess file.

Step::1 Login to your cPanel and click on File Manager section

Step::2 Here go inside public_html and open the directory where you want to disable PHP execution

Step::3 Once you are inside that directory, click on the + File icon at the to left corner of the screen.

Step::4 Create a .htaccess file (You can ignore this step if .htaccess file is already present in the directory)

Step::5 Now right click over the htaccess file and choose the Edit option

Step::6 Next you are going to see a pop-up. Click Edit and a new tab will open

Step::7 Add the code given below
<Files *.php>
    Order deny,Allow
    Deny from all
</Files>

Step::8 Click on Save Changes tab.

In this way you could protect php execution in a specific directory.

Visit our Blog for more details. You can also watch the video here.
  • How to protect PHP file execution in a specific directory, How to Disable PHP Execution in specific directories
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to prevent Cross Site Scripting(XSS) injection attack in your Website?

Cross-site Scripting (XSS) is a client-side code injection attack. The attacker aims to execute...

How to Create backup & store them remotely in any Server using SCP?

Step::1 Login to cPanel and go to Backup Wizard in Files section.Step::2 Now click over Backup...

How to find all http in your website and replace them with https in cPanel?

Step::1 Login to your cPanel and open File ManagerStep::2 Next go inside public_html and create a...

How to secure ‘public html’?

Permissions can be very important when it comes to hosting your website. Permissions can allow...

How to Setup file permissions of any file in cPanel?

Permissions can be very important when it comes to hosting your website. Permissions can allow...