Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request-URI Too Large [duplicate]

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

Request-URI Too Large

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

What is a workaround for this problem?

like image 863
Jasper Avatar asked Mar 26 '12 18:03

Jasper


People also ask

How do I fix request-URI too long?

In the case of the 414 Request-URI Too Large error, the problem is clear: the URLs being passed to the server are too big. To fix it, you'll need to change your Apache or Nginx server settings. This doesn't take too long, and once you're done, you should be back up and running.

What is URI too large?

The HTTP 414 URI Too Long response status code indicates that the URI requested by the client is longer than the server is willing to interpret.

What is a requested URI?

5.1. The Request-URI is a Uniform Resource Identifier (section 3.2) and identifies the resource upon which to apply the request. Request-URI = "*" | absoluteURI | abs_path | authority. The four options for Request-URI are dependent on the nature of the request.


2 Answers

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

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)
like image 199
Luca Rainone Avatar answered Sep 28 '22 04:09

Luca Rainone


This worked for me (it needs formData support):

<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>
like image 29
nicolascolman Avatar answered Sep 28 '22 04:09

nicolascolman