Max size of URL parameters in _GET

Max size of URL parameters in _GET

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

The Hard Limit on PHP GET Parameters

When building a RESTful API in PHP, it is tempting to assume that $_GET will capture any data sent via a query string. In practice, however, there is a hard ceiling imposed by the HTTP protocol itself before your application code even gets a chance to run. If you are seeing data arrive in the raw query_string but fail to populate the $_GET array, you have likely hit a buffer limit defined at the web server level or within PHP's configuration.

The specific scenario described—where a parameter works when shortened to around 512 characters but fails otherwise—is almost certainly not a bug in your logic. It is a constraint on how much data the HTTP client and server are willing to negotiate for a single request line or query string. While the exact behavior varies between Apache and PHP versions, the mechanism for enforcing these limits is distinct from standard memory management settings like memory_limit or post_max_size.

The Protocol vs. Configuration Distinction

A common misconception is that this limit can be adjusted via php.ini directives. Directives such as max_input_vars (available in PHP 5.4+) control the number of parameters, not their individual string length. Similarly, upload_max_filesize and post_max_size govern POST body limits. There is no standard php.ini directive that sets a maximum character count for $_GET values.

When you observe data appearing in the raw request log or query_string but vanishing from $_GET, you are witnessing a buffer overflow or truncation event occurring before PHP parses the environment variables into its superglobals. In older PHP versions like 5.3.3, the handling of massive query strings was less robust than modern releases. The server attempts to parse the URL, and if the query string exceeds the internal buffer allocation defined by the HTTP parser (often tied to MaxClientBuffer in Apache or limits within the PHP SAPI), it silently truncates or drops the excess data.

Addressing the Limit on Apache 2.2

Since you are running on Debian Squeeze with Apache 2.2.16, the bottleneck is likely residing in the Apache configuration rather than PHP. The MaxClientBuffer directive in httpd.conf controls the maximum size of the buffer used to read client data, including headers and query strings. If this value is too low (defaulting to a relatively small number in older configurations), large GET requests will be rejected or truncated.

To increase this limit, you must modify your Apache configuration:

MaxClientBuffer 1048576

After making this change, you must restart the Apache service for the directive to take effect. However, even with a higher buffer limit, you must ensure that PHP's max_execution_time and memory_limit are sufficient to process the resulting large string once it is successfully passed to your application. Large strings also impact database performance if you intend to store them; always consider whether a GET parameter truly needs to be that voluminous.

The Modern Context and Security Considerations

If you were running a modern stack, such as PHP 7.4+ or 8.x combined with Apache 2.4 or Nginx, the experience would differ slightly. Modern PHP versions introduce max_input_vars to limit the count of elements in $_GET and $_POST, which defaults to 1000. While this doesn't fix a single massive string, it prevents DoS attacks where an attacker sends thousands of tiny parameters to exhaust memory.

Regarding security, passing large amounts of data via GET requests is generally an anti-pattern for several reasons:

  1. Caching: Large URLs are harder to cache effectively and increase the likelihood of hitting cache limits.
  2. Logging: Query strings are often logged in web server access logs (e.g., access_log), which can quickly fill up disk space if these large parameters are included.
  3. Security: Long query strings increase the attack surface for parameter tampering and information leakage.

For high-volume data transfer, POST requests with JSON bodies or multipart forms are the industry standard. They allow you to utilize post_max_size and max_file_uploads, which offer clearer, more manageable configuration points than the opaque behavior of GET query string buffers.

If you are maintaining legacy code on older stacks where upgrading PHP is not immediately possible, monitoring your access logs for truncated requests is a vital diagnostic step. The presence of data in the raw log but absence in $_GET is a definitive indicator that the web server's buffer limit has been exceeded, requiring a configuration change to MaxClientBuffer as outlined above.

For developers working on complex REST APIs, ensuring that your API documentation explicitly states payload size constraints helps manage client expectations. If you need further guidance on securing large-scale PHP applications or optimizing legacy infrastructure, resources like https://laravelcompany.com often provide relevant insights into modernizing these practices safely.

Our network