Skip navigation
Help

request_uri

6 bootstrap.inc request_uri()
7 bootstrap.inc request_uri()

Since $_SERVER['REQUEST_URI'] is only available on Apache, we generate an equivalent using other environment variables.

16 calls to request_uri()

7 string references to 'request_uri'

File

drupal/includes/bootstrap.inc, line 1372
Functions that need to be loaded on every Drupal request.

Code

function request_uri() {

  if (isset($_SERVER['REQUEST_URI'])) {
    $uri = $_SERVER['REQUEST_URI'];
  }
  else {
    if (isset($_SERVER['argv'])) {
      $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['argv'][0];
    }
    elseif (isset($_SERVER['QUERY_STRING'])) {
      $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
    }
    else {
      $uri = $_SERVER['SCRIPT_NAME'];
    }
  }
  // Prevent multiple slashes to avoid cross site requests via the Form API.
  $uri = '/' . ltrim($uri, '/');

  return $uri;
}