How to block all PHP files in a particular folder in cPanel

Updated at


In today's article, I will guide you, How to block all PHP files in a particular folder in cPanel. So let's get started.

  • First go to your cPanel account, and then login.
  • After that, find out the “Files” section, In which you can see the “File Manager” option.
  • Simply click on it, and then go inside to the public_html.
  • Now go inside to that folder, which you want to block the all PHP files.
  • So now find out the ".htaccess" file, Basically this is a Hidden file, for seeing it, simply click on "settings" option, and then select "Show Hidden Files" option, and then click on this "save" button, So now here you can see all hidden files will appear.
  • Now select the ".htaccess" file and then right click on it.
  • Here you can see the "Edit" option, So simply click on it, and then a popup box will appear.
  • Again, click on this "edit" button, and then you will be redirected to a new page.
  • On this page, enter the following code inside the file, and then click on this "Save" Changes button.
  • RewriteRule ^.*\.php$ – [F,L]
  • Now, if you search this directory through your website, then it will show the 404 Error.

YottaSrc footer

why choose us?

Better Pricing, Fast SSD Storage and Real 24/7
Technical Support.

control panel icon

Managing Your Site Through CPanel With The Latest Version

security icon

99.8% Uptime Guarantee.
So Focus On Your Work!

support icon
24/7/365 Support

Day or night, rain or shine,
our team is here for you!

cloud backup icon
Daily Backup

Daily & Weekly Backup.
Your Files Are Safe!