是否有可能将用户redirect到file too big
页面
当POST请求大小超过指定的限制?
我知道max-request-size选项,但是它只给出了不能被重载的静态页面。
我想创build一个重写规则
内容大小从请求主体作为input并redirect到错误页面
UPDATE
现在我们使用nginx作为前端。 有什么新build议?
你应该能够做到这一点使用像这样的东西:
server { server_name example.com; 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 }
不要忘记在php.ini
中将post_max_size
和upload_max_filesize
设置为相应的值。
关于@quanta的post,你也可以把一个较低的价值在PHP和使用PHP来显示错误,并使正确的redirect。 它可以在其他脚本语言也可以:-)