How to avoid Request Entity Too Large 413 error

2020-02-04 07:04发布

How to avoid this 413 error ?

Request Entity Too Large

The requested resource /serverpath/reports.php does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.

Apache Server at demo3.website_name Port 80

So, could any one please help to set php.ini and how to set htaccess to allow overwrite status

标签: php .htaccess
5条回答
时光不老,我们不散
2楼-- · 2020-02-04 07:15

Try to look for the following line in the php.ini and set it to the size that you require:

post_max_size = 25M

You can then set it in the .htaccess file:

php_value post_max_size 25M
查看更多
Juvenile、少年°
3楼-- · 2020-02-04 07:17

Unbeknownst to me, a backslash was being added to a custom font field in a WP Plugin that I had, and another character was being added every time I navigated away from the page. Eventually I had a massive string of //////////s and this resulted in a "request entity too large' error. MY ISP upped the max post and vars = in my .ini but this did not solve the problem. It was solved immediately upon discovery and removal of the massive text string. Hope this helps someone else.

查看更多
该账号已被封号
4楼-- · 2020-02-04 07:33

How to fix it in NGINX? client_max_body_size

To fix this, you need to increase the value of the client_max_body_size directive. This directive defines the maximum amount of data Nginx will accept in an HTTP request. By default this value is set to 1 megabyte, meaning if you attempt to upload a file larger than 1 megabyte you'll be getting an Error 413: Request entity too large page. You can insert this directive at three levels:

  • In the http block: this will set the directive value for all server and locations in your configurationn

  • In the server block: this will set the directive value for all locations of one particular server

  • In the location block: this will set the directive value for one specific location in a particular server

In this example I'm going to insert it in my http block and set it to 500 megabytes:

http {

    client_max_body_size 500M; # allows file uploads up to 500 megabytes
    [...]
}

source: http://cnedelcu.blogspot.com.ar/2013/09/nginx-error-413-request-entity-too-large.html

查看更多
淡お忘
5楼-- · 2020-02-04 07:37

On Apache 2.4 it is worth looking at the LimitRequestBody directive as well. It can be configured per vhost and it goes into the <Directory> section.

<VirtualHost *:80> 
  [...]
  <Directory "/var/www/public_html"> 
    [...]
    LimitRequestBody 33554432 
  </Directory> 
</VirtualHost> 

The size value is in bytes. This finally solved it for me when I tried both the php.ini max size directives and was still getting errors.

查看更多
We Are One
6楼-- · 2020-02-04 07:39

php.ini has a setting called post_max_size, which is set to 8M by default (on Ubuntu at least).

Consider increasing that value if you are posting a lot of data.

查看更多
登录 后发表回答