How do I resolve a HTTP 414 "Request URI too long" error?
I have developed a PHP web app. I am giving an option to the user to update multiple issues on one go. In doing so, sometimes the user is encountering this error. Is there any way to increase the lenght of URL in apache?
Verified Answer (163 Votes) ✓
Under Apache, the limit is a configurable value,
LimitRequestLine. Change this value to something larger than its default of 8190 if you want to support a longer request URI. The value is in /etc/apache2/apache2.conf. If not, add a new line (
LimitRequestLine 10000) under
However, note that if you're actually running into this limit, you are probably abusing
GET to begin with. You should use
POST to transmit this sort of data -- especially since you even concede that you're using it to update values. If you check the link above, you'll notice that Apache even says "Under normal conditions, the value should not be changed from the default."
Answer #2 (15 Votes)
Based on John's answer, I changed the GET request to a POST request. It works, without having to change the server configuration. So I went looking how to implement this. The following pages were helpful:
jQuery Ajax POST example with PHP (Note the sanitize posted data remark) and
Basically, the difference is that the GET request has the url and parameters in one string and then sends null:
http.open("GET", url+"?"+params, true); http.send(null);
whereas the POST request sends the url and the parameters in separate commands:
http.open("POST", url, true); http.send(params);
Here is a working example:
<?php $lorem=$_POST['lorem']; print $lorem.'<br>'; ?>
I just sent over 12,000 characters without any problems.
Answer #3 (3 Votes)
I have a simple workaround.
Suppose your URI has a string
stringdata that is too long. You can simply break it into a number of parts depending on the limits of your server. Then submit the first one, in my case to write a file. Then submit the next ones to append to previously added data.