Namecheap LiteSpeed Problem when Posting data from html form

683 Views Asked by At

I am facing a problem when trying to post data to my PHP from html form. The issue is as follows:

  1. When I submit less data like a 1 paragraph of Lorem Ipsum it works fine.
  2. Submitting more paragraphs it fails instantly with error 403 Forbidden.
  3. Tried solving using SecFilterScanPOST Off on .htaccess but to no avail.

Error message image

2

There are 2 best solutions below

0
On

A solution about disabling should help but it decreases security — stops doing that.

Better to spend more time understanding the main reason and for example configure mod_security for Wordpress:

Based on this article you can disable some rules directly for wp-admin directory:

<LocationMatch "/wp-admin/">
  SecRuleRemoveById 300013
  SecRuleRemoveById 300014
  SecRuleRemoveById 300015
  SecRuleRemoveById 300016
  SecRuleRemoveById 300017
</LocationMatch>

Based on this article you can disable some rules directly for sub-directories:

<LocationMatch "/wp-admin/admin-ajax.php">
  SecRuleRemoveById 300013
  SecRuleRemoveById 300015
  SecRuleRemoveById 300016
  SecRuleRemoveById 300017
  SecRuleRemoveById 949110
  SecRuleRemoveById 980130
</LocationMatch>
<LocationMatch "/wp-admin/page.php">
  SecRuleRemoveById 300013
  SecRuleRemoveById 300015
  SecRuleRemoveById 300016
  SecRuleRemoveById 300017
  SecRuleRemoveById 949110
  SecRuleRemoveById 980130
</LocationMatch>
<LocationMatch "/wp-admin/post.php">
  SecRuleRemoveById 300013
  SecRuleRemoveById 300015
  SecRuleRemoveById 300016
  SecRuleRemoveById 300017
  SecRuleRemoveById 949110
  SecRuleRemoveById 980130
</LocationMatch>

If you want to be sure that mod_security is used you can wrap the settings above in this:

<IfModule mod_security.c>
  # ...
  # <LocationMatch ...>
  # ...
</IfModule>
0
On

To solve this error, @qtwrk's comment is correct that you must use the following code in your .htaccess.

<IfModule mod_security.c>
SecRuleEngine Off
SecRequestBodyAccess Off
</IfModule>

WordPress running on Litespeed Server will often fail with a 403 error when you try to post any content while creating new pages and posts in WP Admin. This code solves that issue.