Is there a way to make a custom return message when LimitRequestBody is exceeded?
i am using LimitRequestBody to cut of the user if he goes past my upload limit. IT returns a message like this
Request Entity Too Large The requested resource /index.php does not allow request data with GET requests, or the amount of data provided in the request exceeds the capacity limit.
Additionally, a 404 Not Found error was encountered while tryi开发者_StackOverflow社区ng to use an ErrorDocument to handle the request. logo
Im not totally sure what it wants here.. but it does get triggered if the user exceeds.
Since LimitRequestBody is at the Apache level (ie, never hits PHP), you need to replace the error document at the Apache level. The way you do that is with ErrorDocument.
From the output Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
, it looks like there is an ErrorDocument set up, but Apache can't find it.
Basically, you will need something like:
ErrorDocument 413 /request-too-large.php
The request-too-large.php file will probably get a standard GET request - any POST parameters will be lost, but you can look inside $_SERVER
and $_REQUEST
to see if there is anything else left over from the original request.
It may take a while to get this right in terms of executing PHP for the error document. If you can't come right doing it directly with PHP, use a plain HTML page, and then set up a META Redirect and/or JavaScript redirect to send you to a PHP page.
You can also set it with a full URL - this will use a client-side redirect.
精彩评论