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?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
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
http://www.openjs.com/articles/ajax_xmlhttp_using_post.php
Basically, the difference is that the GET request has the url and parameters in one string and then sends null:
whereas the POST request sends the url and the parameters in separate commands:
Here is a working example:
ajaxPOST.html:
ajaxPOST.php:
I just sent over 12,000 characters without any problems.
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
) underAccessFileName .htaccess
.However, note that if you're actually running into this limit, you are probably abusing
GET
to begin with. You should usePOST
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."An excerpt from the RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1:
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.I got this error after using $.getJSON() from JQuery. I just changed to post: