How to protect PHP file execution in a specific directory?

How to protect PHP file execution in a specific directory? [STEP BY STEP]☑️

In this article, we will show you how to disable PHP file execution in a specific directory using the .htaccess file. 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. But before getting started watch this short video tutorial on “How to protect PHP file execution in a specific directory” embedded below.

Video Tutorial– “How to protect PHP file execution in a specific directory”

Follow the steps to protect PHP file execution in a specific directory:

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

How to protect PHP file execution in a specific directory

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

How to protect PHP file execution in a specific directory

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

How to protect PHP file execution in a specific directory

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

How to protect PHP file execution in a specific directory

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

How to protect PHP file execution in a specific directory

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

How to protect PHP file execution in a specific directory

Step::7 Add the code given below

<Files *.php>
    Order deny,Allow
    Deny from all
</Files>

How to protect PHP file execution in a specific directory

Step::8 Click on Save Changes tab.

How to protect PHP file execution in a specific directory

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

Thanks for Reading this article !!! We hope this was helpful to you all.

Also Read: Suspend Email Accounts in cPanel

For more information, kindly follow us on social media like Twitter and Facebook and for video tutorials, subscribe to our YouTube channelhttps://youtube.com/redserverhost.com 

Facebook Page https://facebook.com/redserverhost

Twitter Pagehttps://twitter.com/redserverhost.com

If you have any suggestions or problems related to this tutorial, please let us know via the comment section below.

Tags: cheap linux hostingbuy linux hostingcheap reseller hostingbuy reseller hostingbest reseller hostingcheap web hostingcheapest web hostingcheapest reseller hosting,  cheap reseller hostcheap linux hostcheapest linux hostingbest linux hostingbest web hosting

Scroll to Top