If you run WordPress on a cPanel and WHM server and get 403 Forbidden when you log in to wp-login.php or save a post, this article walks you from that symptom to the smallest fix. The public site loads, the password is right, but one request is refused before WordPress even sees it. Most often a ModSecurity rule, the web application firewall (WAF) module inside Apache, has mistaken your password or your post content for an attack. Find the rule ID in the Apache error log, then tell that one rule to ignore that one field on that one URL. The firewall keeps protecting everything else on the server.
What you’ll accomplish
- Tell a ModSecurity 403 apart from a Cloudflare, Wordfence, Imunify360 or
.htaccess403. - Find the rule ID, the URL and the exact field that triggered the block in the EasyApache 4 logs.
- Write a custom rule in WHM that removes one field from one rule, and know when a wider fix is justified.
- Prove the login works again while the rule still blocks the same payload on other URLs.
Prerequisites
- Root SSH access to the server, or a WHM account with access to Security Center » ModSecurity Tools. A cPanel user account cannot read the logs used here.
- cPanel and WHM on EasyApache 4 (EA4) with the Apache ModSecurity 2.9 module. The log line format below is the one ModSecurity 2.9 writes on Apache 2.4.
- A rule set from WHM » Security Center » ModSecurity Vendors. The examples use the OWASP Core Rule Set (CRS), version 3.3, which cPanel lists as the OWASP vendor. Rule IDs such as
942100are the same in CRS 4. - The time of a failed attempt, to the minute. You will search the log around it.
How it works
ModSecurity reads each request in phases. Phase 1 sees the URL and headers. Phase 2 sees the request body, which is where your password (pwd) and post text (content) live. CRS rules do not block on their own. Each match adds points to an anomaly score, and rule 949110 denies the request once the score reaches the threshold, 5 by default. One critical match such as 942100 (SQL injection detected by the libinjection library) is worth 5 points, so it is enough on its own.
That is why a blocked login leaves two lines in the log. The first names the rule that matched your data. The second is 949110 doing the blocking. You exclude the first rule and never 949110, because removing 949110 stops all score-based blocking on the server.
Exclusions come in sizes. The narrowest stops one rule from reading one field on one URL. The widest switches every rule off for a whole domain. Always start at the top of the ladder and move down only when the narrow fix cannot work.
On cPanel, your own rules live in /etc/apache2/conf.d/modsec/modsec2.user.conf, which WHM edits for you. EA4 loads that file before the vendor rules. Runtime rules that use the ctl action therefore run first in each phase, which is what you want. A plain SecRuleRemoveById line in that file can do nothing, because ModSecurity requires it to come after the rule it removes.
Step-by-step
-
Look at the 403 page itself. Each layer that can refuse a request shows a different page and leaves a different trace.
- Apache’s plain “Forbidden” page plus a
ModSecurity: Access deniedline in the error log means ModSecurity. If the rule message starts withIM360 WAF, the rule belongs to Imunify360’s own rule set, and you disable it under Imunify360 Settings » Disabled rules instead. - “Sorry, you have been blocked” with a Cloudflare Ray ID comes from the Cloudflare WAF at the edge. Your server logs nothing.
- “Your access to this site has been limited by the site owner” comes from Wordfence, a WordPress security plugin. Check Wordfence » Tools » Live Traffic.
AH01630: client denied by server configurationin the error log means aRequirerule in.htaccessor the virtual host denied the request.AH01797is the same for oldDeny fromlines.
To skip Cloudflare and talk to your server directly, pin the hostname to the origin IP address:
curl -s -o /dev/null -w '%{http_code}\n' --resolve www.example.com:443:192.0.2.10 https://www.example.com/wp-login.phpA
200means the login page loads from the origin. If the browser still gets the Cloudflare page, the block is at the edge, and the rest of this article does not apply. - Apache’s plain “Forbidden” page plus a
-
Confirm where EA4 writes its logs. On EA4,
/etc/apache2/logsis the log directory and points into/var/log/apache2. The old EasyApache 3 path/usr/local/apache/logsmay still exist as a symlink for compatibility.readlink -f /etc/apache2/logs /usr/local/apache/logsExample output:
/var/log/apache2 /var/log/apache2Two identical lines mean every path name leads to the same files. If the second path does not exist, ignore it and use
/etc/apache2/logs.Now check how the audit log is written:
grep -rn '^ *SecAuditLog' /etc/apache2/conf.d/ 2>/dev/nullExample output:
/etc/apache2/conf.d/modsec2.conf:9:SecAuditLogType Serial /etc/apache2/conf.d/modsec2.conf:10:SecAuditLog logs/modsec_audit.logSerialmeans one file,/etc/apache2/logs/modsec_audit.log. When the server runsmod_ruid2or thempm_itkmodule, cPanel logs concurrently instead, one small file per request under/etc/apache2/logs/modsec_audit/<username>/. You rarely need the audit log for this fix, because the error log line already holds the rule ID, the field and the URL. -
Find the rule that matched. Reproduce the failure once in the browser, then search the error log:
grep 'ModSecurity' /etc/apache2/logs/error_log | grep -E 'wp-login\.php|/wp-admin/|/wp-json/' | tail -n 2Example output:
[Tue Oct 20 09:14:22.481203 2026] [security2:error] [pid 30412:tid 140203817445120] [client 203.0.113.44:54212] ModSecurity: Warning. detected SQLi using libinjection with fingerprint 's&1c' [file "/etc/apache2/conf.d/modsec_vendor_configs/OWASP3/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "46"] [id "942100"] [msg "SQL Injection Attack Detected via libinjection"] [data "Matched Data: s&1c found within ARGS:pwd: Tq9'or 1#Lake"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.10"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-sqli"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/66"] [tag "PCI/6.5.2"] [hostname "www.example.com"] [uri "/wp-login.php"] [unique_id "ZxUgfnXQmJ0AAHdMQ2cAAAAG"], referer: https://www.example.com/wp-login.php [Tue Oct 20 09:14:22.483977 2026] [security2:error] [pid 30412:tid 140203817445120] [client 203.0.113.44:54212] ModSecurity: Access denied with code 403 (phase 2). Operator GE matched 5 at TX:anomaly_score. [file "/etc/apache2/conf.d/modsec_vendor_configs/OWASP3/rules/REQUEST-949-BLOCKING-EVALUATION.conf"] [line "81"] [id "949110"] [msg "Inbound Anomaly Score Exceeded (Total Score: 5)"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.10"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-generic"] [hostname "www.example.com"] [uri "/wp-login.php"] [unique_id "ZxUgfnXQmJ0AAHdMQ2cAAAAG"], referer: https://www.example.com/wp-login.phpRead four fields from the first line.
idis the rule to exclude, here942100.found within ARGS:pwdnames the field, here the password box.uriis the URL, here/wp-login.php.unique_idlets you find the full request in the audit log if you need it. The log records what was typed, so change that password once the login works.For a post save, the URL is
/wp-admin/post.phpwith the classic editor. The block editor saves through the REST API (the WordPress JSON interface), for example/wp-json/wp/v2/posts/412, and shows “Updating failed” instead of a 403 page. Copy the field name exactly as the log prints it, such asARGS:contentorARGS:json.content.With many hits, count them by rule, field and URL:
sed -nE 's/.*\[id "([0-9]+)"\].*found within ([A-Za-z_]+:[^:]+):.*\[uri "([^"]+)"\].*/\1 \2 \3/p' /etc/apache2/logs/error_log | sort | uniq -c | sort -rn | head -n 5Example output:
3 942100 ARGS:pwd /wp-login.php 1 941160 ARGS:content /wp-admin/post.php941160is the CRS rule for HTML injection, which an<iframe>embed in a post can trigger. -
Remove one field from one rule (narrowest). In WHM, open Security Center » ModSecurity Tools, select Rules List, then Add Rule. Paste the rule, tick Deploy and Restart Apache, and save. WHM stores it in
modsec2.user.conf.SecRule REQUEST_FILENAME "@endsWith /wp-login.php" \ "id:1000101,phase:1,pass,nolog,t:none,ctl:ruleRemoveTargetById=942100;ARGS:pwd"REQUEST_FILENAMEis the URL path without the query string, so@endsWithalso matches WordPress installed in a subfolder. Phase 1 is right here because the URL is known before the body is read, and thectlaction must run before rule942100does in phase 2. Use phase 2 only when your condition needs a body field, and keep the rule in this file so it still runs first. For the post save, use the same pattern with your own values:SecRule REQUEST_FILENAME "@endsWith /wp-admin/post.php" \ "id:1000102,phase:1,pass,nolog,t:none,ctl:ruleRemoveTargetById=941160;ARGS:content"Every rule ID on the server must be unique, or Apache refuses to start. Pick a block such as
1000101and up, and never reuse a number. -
Remove one rule for one URL (wider). When the same rule fires on several fields of one URL, drop the rule for that URL only:
SecRule REQUEST_FILENAME "@endsWith /wp-login.php" \ "id:1000103,phase:1,pass,nolog,t:none,ctl:ruleRemoveById=942100"Older answers wrap
SecRuleRemoveByIdin a<LocationMatch>block. On cPanel thectlform above is the safer choice, because it does not depend on the order in which Apache reads the files. -
Turn on the CRS WordPress exclusions (wider still). These are rules from the CRS project that skip known WordPress fields, such as
pwdonwp-login.phpandcontenton the editor’s REST routes. First check your CRS version:grep -rhoE -m1 'OWASP_CRS/[0-9.]+' /etc/apache2/conf.d/modsec_vendor_configs/ | sort -uExample output:
OWASP_CRS/3.3.10On CRS 3, the exclusions ship in
REQUEST-903.9002-WORDPRESS-EXCLUSION-RULES.confand stay off untiltx.crs_exclusions_wordpressis set to 1. Add this through Add Rule so a vendor update does not overwrite it:SecAction "id:1000104,phase:1,pass,nolog,t:none,setvar:tx.crs_exclusions_wordpress=1"CRS 4 removed the built-in exclusions. You install the official WordPress Rule Exclusions plugin instead, following the CRS plugin documentation. It covers WordPress core only, so page builder or form plugin false positives still need step 4.
-
Disable one rule for the whole server (last but one). In ModSecurity Tools » Rules List, search for the rule ID, click Disable, then Deploy and Restart Apache. You can also open the Hits List and click the Rule ID of a hit. The rule now stops for every site on the server, so keep this for rules that misfire everywhere.
-
Switch ModSecurity off for one domain (last resort). In cPanel, open Security » ModSecurity and set the domain to Off under Configure Individual Domains. That domain then gets no ModSecurity rules at all, login form included. Turn it back On as soon as a narrower rule is in place.
-
Test the syntax and reload Apache. WHM restarts Apache when you tick the deploy box. After any edit made over SSH, test the configuration first:
apachectl configtestExpected output:
Syntax OKAnything else means the new rule has an error, and Apache would refuse it. Fix the line it names before going further. Then restart Apache through cPanel’s script and confirm the service is up:
/usr/local/cpanel/scripts/restartsrv_httpd systemctl is-active httpdThe last line should print
active. If it printsfailed, runapachectl configtestagain and read the error.
Validate it works
Log in through the browser with the account that failed. Then send the same password to the login page and to the home page:
curl -s -o /dev/null -w '%{http_code}\n' --data "log=nobody&pwd=Tq9'or 1#Lake" https://www.example.com/wp-login.php
curl -s -o /dev/null -w '%{http_code}\n' --data "s=Tq9'or 1#Lake" https://www.example.com/
Example output:
200
403
200 on wp-login.php means the request reached WordPress, which answered with its normal login page and an error message. 403 on the home page means rule 942100 still blocks the same string everywhere else. A 403 on both lines means your exclusion did not load. A 200 on both means something switched the rule off more widely than you meant. Last, confirm no new 942100 line appeared for /wp-login.php:
grep -c 'id "942100".*uri "/wp-login.php"' /etc/apache2/logs/error_log
The count should stay at the number you saw before the test.
Troubleshooting
Apache will not restart after you add the rule. apachectl configtest prints AH00526: Syntax error with ModSecurity: Found another rule with the same id. Two rules share an ID. Search /etc/apache2/conf.d/modsec/modsec2.user.conf for the number and change yours.
The rule still fires after the exclusion. Check three things. The URL in your condition must match the uri field exactly, including subfolders. The field name must match found within exactly, so ARGS:json.content is different from ARGS:content. And a global SecRuleRemoveById or SecRuleUpdateTargetById line in modsec2.user.conf loads before the vendor rules, so it removes nothing. Use the ctl form.
A second rule appears as soon as the first is fixed. CRS SQL and cross-site scripting (XSS) rules overlap, so one password can match two rules. Repeat step 3 for the new ID. Past three rules on one URL, use step 6 instead of more single exclusions.
No ModSecurity line appears, yet the 403 remains. The block comes from another layer. Recheck the page text from step 1, and see the general cPanel 403 checklist for permission and .htaccess causes.
The unique_id is missing from the audit log. The log rotated, or the server logs concurrently. Search the per-user folder instead: grep -rl <unique_id> /etc/apache2/logs/modsec_audit/<username>/. To read a full transaction, see reading the ModSecurity audit log on cPanel.
When this is the wrong approach
If the matched data looks like a real attack, such as ' OR 1=1-- from an IP address you do not know, ModSecurity is doing its job. Leave the rule alone and add login rate limiting instead. If the same rule ID fires across many unrelated accounts, the vendor rule set or its paranoia level does not fit your sites, and per-URL exclusions will keep piling up. If Cloudflare sits in front of the server and every client address in the log is a Cloudflare address, fix the real client IP first. The cPanel ModSecurity Tools documentation describes each WHM screen used above.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.