Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is it possible to redirect user to file file too big page

when POST request size exceeds specified limit?

I am aware about max-request-size option, but it gives just static page that cannot be overloaded.

I am thinking to create a rewrite rule which takes

content-size from request body as input and redirects to error page


now we use nginx as front-end. Any new suggestions?

share|improve this question

migrated from Jun 7 '11 at 7:53

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 14 down vote accepted

You should be able to do this using something like:

server {

  client_max_body_size 10m; # or whatever size limit you want
  error_page 413 /custompage.html; # you can also use a named location here if you like
share|improve this answer
but this won't work with most of modern browsers - unfortunaley they can't handle 413 properly. So, I'm afraid there's no solution to this problem (well, unless you can patch all current browsers) – rvs Sep 21 '11 at 18:38
You can change the status code to anything else with error_page if you don't want to actually return 413 to the client. error_page 413 =403 /custompage.html; will use 403, for example. – kolbyjack Sep 21 '11 at 18:42

Don't forget to set post_max_size and upload_max_filesize to corresponding value in php.ini.

share|improve this answer
We are not at php. – jonny Jan 21 at 11:02

Regarding @quanta post, you can also put a lower value in php and use php to display the error and make the redirection correctly. It can be made in other scripting languages also :-)

share|improve this answer
I didn't mention our server side stack. PHP <> whole world :) – jonny Jan 21 at 11:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.