Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Request.php

function Request::getBaseUrl

Returns the root URL from which this request is executed.

The base URL never ends with a /.

This is similar to getBasePath(), except that it also includes the script filename (e.g. index.php) if one exists.

Return value

string The raw URL (i.e. not urldecoded)

3 calls to Request::getBaseUrl()
Request::getUri in vendor/symfony/http-foundation/Request.php
Generates a normalized URI (URL) for the Request.
Request::getUriForPath in vendor/symfony/http-foundation/Request.php
Generates a normalized URI for the given path.
Request::prepareBasePath in vendor/symfony/http-foundation/Request.php
Prepares the base path.

File

vendor/symfony/http-foundation/Request.php, line 828

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public function getBaseUrl() : string {
    $trustedPrefix = '';
    // the proxy prefix must be prepended to any prefix being needed at the webserver level
    if ($this->isFromTrustedProxy() && ($trustedPrefixValues = $this->getTrustedValues(self::HEADER_X_FORWARDED_PREFIX))) {
        $trustedPrefix = rtrim($trustedPrefixValues[0], '/');
    }
    return $trustedPrefix . $this->getBaseUrlReal();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal