Apache 413 Request Entity Too Large
On a CentOS server, when uploading a 100 MB video file in WordPress media manager, I got the following error message
1 2 3 |
Request Entity Too Large The requested resource /wp-admin/async-upload.php does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit. |
The server had mod_security installed. I edited the mod_security config file
1 |
vi /etc/httpd/conf.d/mod_security.conf |
Set following for values and restart Apache.
1 2 3 |
SecRequestBodyLimit 1073741824000 SecRequestBodyNoFilesLimit 1073741824000 SecRequestBodyInMemoryLimit 1073741824000 |
But I still get the same error. So I disabled mod_security by moving the config file to a temporary directory and restarting apache.
The error was due to Apache setting LimitRequestBody, the error is fixed by adding “LimitRequestBody 0” in the .htaccess file used by WordPress.
1 |
LimitRequestBody 0 |
Now when I enable mod_security, I get 500 error, I disabled mod_seurity for the file upload PHP script used by WordPress by editing the Apache VirtualHost entry of the website and adding
1 2 3 |
<If "%{REQUEST_URI} =~ m#/wp-admin/async-upload.php#"> SecRuleEngine Off </If> |