php 请求 URI 太大

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9877744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 07:51:02  来源:igfitidea点击:

Request-URI Too Large

phpgetrequestcapacity

提问by Jasper

Got this error on a big $_GETquery in size ~9 000 symbols (they are divided into ~10 variables).

$_GET在大小为 ~9 000 个符号的大查询中遇到此错误(它们分为 ~10 个变量)。

Request-URI Too Large

The requested URL's length exceeds the capacity limit for this server.

What is a workaround for this problem?

此问题的解决方法是什么?

采纳答案by Luca Rainone

There is no workaround if you want pass all these info with GET without change server configuration.

如果您想在不更改服务器配置的情况下使用 GET 传递所有这些信息,则没有解决方法。

Other solutions:

其他解决方案:

  • Use POST with a form (or an hidden form and add onclick event at your link that submit it)
  • Use Session. When the server generates the link, store it in $_SESSION with an unique id (or RID, it can be md5 of complete URI) and pass it via GET.
  • Use Database or file storage (with the same procedure of session)
  • 将 POST 与表单一起使用(或隐藏表单并在提交它的链接上添加 onclick 事件)
  • 使用会话。当服务器生成链接时,将其存储在 $_SESSION 中,并带有唯一 id(或 RID,可以是完整 URI 的 md5)并通过 GET 传递。
  • 使用数据库或文件存储(与会话过程相同)

回答by nicolascolman

This worked for me (it needs formData support):

这对我有用(它需要 formData 支持):

<script>
  //Load form
  var formData = new FormData();
  formData.append("param_name1", "param_content1");
  formData.append("param_name2", "param_content2"); 
  formData.append("param_nameN", "param_contentN"); 

  //Send form via AJAX
  var xhr = new XMLHttpRequest();
  xhr.open("POST", YOUR_URL);  
  xhr.send(formData);
</script>

回答by Croo

Well an URI actually have a character limit depending on several things. You can check it out at

一个 URI 实际上有一个字符限制,这取决于几个方面。你可以在

One workaround is to use POST instead of GET if you are the one developing the server too.

如果您也是开发服务器的人,则一种解决方法是使用 POST 而不是 GET。