Skip to content

Blocking Direct PHP File Access on Cloudways: What It Blocks, What Keeps Working, and How to Test It

On this page

Last updated: · By

In short: the Direct PHP File Access option in the Cloudways dashboard blocks direct execution of PHP files in the wp-content and wp-includes folders, above all uploads, where attackers like to plant webshell files. On my site it took one click, a confirmation and about 20 seconds. Afterwards, direct requests to plugin PHP files got a 403, while the site, the REST API, the sitemap, wp-cron and admin-ajax kept working. No plugin broke (measured 7 Nov 2026).

⏱ Time needed: 2 minutes, plus 10 minutes for testing · Difficulty: easy · Last tested against my own dashboard and site: 7 Nov 2026

In short: what happened on my site after the block (measured 7 Nov 2026)

What I checkedResult
Time to enableOne click and a confirmation, about 20 seconds, with no downtime for the site
PHP files under wp-content/plugins, uploads and wp-includes403 on a direct request
Homepage, REST API (wp-json), sitemap, wp-cron.php200, same as before
admin-ajax.phpWorks (400 without an action parameter, which is WordPress’s normal response)
PluginsElementor Pro, Yoast, Imagify, Redirection and Object Cache Pro all work, no errors
xmlrpc.phpWas already blocked with a 403 before, at the Cloudflare layer
wp-login.php with curl403, but from the existing Cloudflare challenge and not from this block. A normal browser gets through

What is Direct PHP File Access on Cloudways?

It is an application-level setting that decides whether anyone may browse directly to the address of a PHP file inside WordPress’s content and core folders. When access is blocked, the server refuses to run a file like /wp-content/uploads/2026/11/x.php even if someone managed to upload it.

WordPress itself doesn’t need this access. Every page on the site loads through index.php in the root, and plugins are loaded from inside it. The PHP files inside the folders are included by code, and aren’t supposed to be opened directly from the browser.

According to the Cloudways help article, on a new application direct access is blocked by default. On older applications, or ones someone opened in the past, it may be open. On my site it was open until 7 Nov 2026.

Why block direct access to PHP files?

Because it is the most common way an attacker turns a plugin vulnerability into full control of a site. An attacker who exploits a file upload weakness plants a small PHP file, a webshell, then simply browses to it and runs commands on the server.

The security organization OWASP describes exactly this scenario and recommends that the uploads folder have no execute permission. The official WordPress hardening guide also recommends blocking access to PHP files in wp-includes as an additional layer of protection.

It isn’t theoretical. In the case of the hack through the WP File Manager plugin, the malicious files sat inside wp-content. A block like this does not prevent the upload, but it stops the uploaded file from running when someone browses to it. It is one layer out of several, and not a substitute for malware protection and plugin updates.

What should you do before you turn the block on?

  • Back up the application. The block doesn’t touch any files, but a fresh backup is a good habit before any change. See backup and restore on Cloudways.
  • Run the curl test below and save the results. Without a “before”, it is hard to know what changed.
  • Write down any plugins that have a PHP file called directly from outside: a download script, a payment callback, an old image generator. Those are the candidates to break.
  • Is it a sensitive site (a store, payment forms)? Try it first in a Staging environment.

How do you block Direct PHP File Access in the dashboard? Step by step

  1. Log in to the dashboard and choose My Applications, then your site.
  2. Under Application Management choose Application Settings.
  3. Go to the WordPress tab at the top of the screen and scroll to Direct PHP File Access.
  4. Note the reversed wording: according to Cloudways, Disable means direct access is blocked, and Enable means it is allowed. If the switch is on, turn it off.
  5. Confirm in the pop-up with Confirm. On my site the confirmation message appeared in the corner after about 20 seconds.

How do you test with curl that the block works?

You run the same list of addresses before and after, and compare the response codes. The blocked addresses should switch to 403, and the addresses of the live site should stay at 200.

for p in / /wp-json/ /sitemap_index.xml /wp-cron.php /wp-admin/admin-ajax.php \
  /wp-content/plugins/wordpress-seo/wp-seo.php /wp-includes/version.php \
  /wp-content/uploads/test.php; do
  printf "%s " "$p"; curl -s -o /dev/null -w "%{http_code}\n" "https://example.com$p"
done

Replace example.com with your domain, and wp-seo.php with a file from a plugin installed on your site. The file test.php doesn’t need to exist: after the block, even a PHP file that doesn’t exist in such a folder gets a 403, because the rule works by path.

Did the 403 come from the server or from Cloudflare?

If your site is behind Cloudflare, check the body of the response. According to the Cloudflare documentation, a 403 page with their branding comes from Cloudflare, and a page without branding comes from the server.

This matters, because on my site it turned out there are two layers. In a repeat test on 7 Nov 2026, some of these addresses got Cloudflare’s “Attention Required” page, which means a security rule at the edge blocks them too, before the request ever reaches the server. To test the dashboard setting alone, run the test against the Cloudways application address, which doesn’t go through Cloudflare. For reading security events at the edge, see Cloudflare security events.

Black Friday80% off
80% off 2 months of managed hosting

The code BFCM802 takes 80% off your bill for the first two months (up to $200 off per month), including unlimited free site migrations. New customers only, and only until the offer ends.

The offer ends on December 4, 2026 at 23:59 (UTC+2).

Ends in—days—hours—minutes—seconds
Code:
Grab the 80% now

Start with a free trial, no credit card. Enter the code at checkout and check that it shows up.

After Black Friday: 30% off for 3 months with the code ASAEL. On a large server (above about $444 a month) ASAEL already saves more today. BFCM802 vs. ASAEL calculator

What can break after the block?

Only a plugin or theme that expects the browser or an external service to call one of its PHP files directly. Modern plugins work through the REST API or admin-ajax, so they are not affected.

WhatAffected?How to spot it
Pages, posts, cart and checkoutNo, they load through index.php200 on the homepage and pages
REST API, admin-ajax, wp-cronNo, tested on my sitewp-json returns 200
An old payment or shipping callback that points to a file in the plugin folderYes, it may breakThe payment goes through but the order isn’t updated, 403 in the access log
A download script, or an old captcha or image generatorYes, it may breakA broken image or a download link that returns 403

The last two rows are my estimate based on how the block works, not a case I saw. On my site, with Elementor Pro, Yoast, Imagify, Redirection and Object Cache Pro, nothing broke.

Did something break? First check in the guide to the 403 error that the block is really the cause. If it is, there are two ways: ask the plugin developer for a REST API endpoint, or replace the plugin. I didn’t find an option in the Cloudways documentation to exempt a single file, so you can also ask support.

How do you undo the block if you need to?

With the same switch. Go back to Application Settings, the WordPress tab, switch Direct PHP File Access to Enable and confirm. According to Cloudways it is the same process in the opposite direction, and it doesn’t change any files on the site.

Don’t leave access open for no reason. If you opened it for a single plugin, plan to replace that plugin and block again.

What else did I check in the same hardening round?

  • XML-RPC: already blocked with a 403 at the Cloudflare layer, so there was nothing to change.
  • wp-login.php: returns 403 to curl because of an existing Cloudflare challenge. A normal browser passes the challenge and logs in.
  • Cron Optimizer: I did not enable it. WP-Cron is already off (DISABLE_WP_CRON) and runs from a server cron, so the option is unnecessary on my site. See scheduled tasks on Cloudways.

The full list of hardening steps in the dashboard is in the guide to improving security on Cloudways, and the bigger picture is in the website security guide.

Common mistakes

Mixing up the direction of the switch: Disable means blocking. After the change, confirm with curl that a plugin file returns 403.

Thinking it cleans up malware: the block prevents execution, it doesn’t delete files. If you have already been hacked, go to removing malware from WordPress.

Blaming every 403 on the block: on a site behind Cloudflare, many 403s come from the edge. Check the error page before you undo anything.

Frequently asked questions

Does blocking Direct PHP File Access break the site?

Usually not. On my site, with Elementor Pro, Yoast, Imagify, Redirection and Object Cache Pro, everything kept working on 7 Nov 2026. Only a plugin that calls a PHP file in its own folder directly may break.

How long does it take to turn the block on in Cloudways?

About 20 seconds. You click the switch in Application Settings, WordPress tab, and confirm in the pop-up. The site doesn’t go down in the middle.

Is the block enabled by default?

According to Cloudways, on a new application direct access to PHP files is blocked by default. On older applications it may be open, so it is worth checking. On my site it was open until I blocked it.

Do admin-ajax and the REST API keep working?

Yes. In my test wp-json returned 200 and admin-ajax.php answered as usual. wp-cron.php and the sitemap also returned 200 after the block.

Does the block replace a security plugin or a malware scan?

No. It stops a planted PHP file from running when someone browses to it, but it doesn’t prevent the upload and doesn’t clean existing files. You still need plugin updates, scanning and backups.

How do you tell whether a 403 came from Cloudways or from Cloudflare?

By the error page. A page with Cloudflare branding, such as Attention Required, comes from the edge. A page without branding comes from the server. For a clean test of the server, test against the Cloudways application address.

Sources

Official source: Restrict Direct Access to WordPress PHP Files (Cloudways Knowledge Base). This page was written and tested by Asael Dreyer · Updated: 7 Nov 2026

Disclosure: this is an independent site, not the official Cloudways site. Some links on this site are affiliate links: if you sign up through them we earn a commission, at no extra cost to you. Full details

Picture of Asael Dreyer
Asael Dreyer

Hi, I'm Asael Dreyer, CEO of an SEO agency that runs hundreds of websites hosted on dozens of Cloudways servers.
Everything you will find here comes from hands-on experience, mine and my teams', straight from the field: from the guides to the recommendations. All to help you get the most out of Cloudways.

More about me →

Need help? Got a question about your server or this guide? Write to us and we will get back to you.

More guides on this topic:
מפריד
Thanks for your message!
We will get back to you soon.
Ready to get started?

Sign up with the coupon code ASAEL