10

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?

hakre
  • 193,403
  • 52
  • 435
  • 836
Jasper
  • 5,090
  • 11
  • 34
  • 41

3 Answers3

8

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)
Luca Rainone
  • 16,138
  • 2
  • 38
  • 52
  • See as well: [How to compress/decompress a long query string in PHP?](http://stackoverflow.com/questions/2996049/how-to-compress-decompress-a-long-query-string-in-php) – hakre Jun 23 '12 at 11:52
  • I think that in this way you just move the problem in the future, when the url will be too large with compression as well. It's better to change logic if you need to pass too much info via get. (My 2 cents) – Luca Rainone Oct 09 '13 at 19:20
  • That is a related question only, if you read the accepted answer there, you can even see that this is *not* so much in the future but already in the past. – hakre Oct 10 '13 at 05:50
1

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>
nicolascolman
  • 549
  • 4
  • 15
0

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

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

Croo
  • 1,301
  • 2
  • 13
  • 32