drupal_detect_baseurl
- Versions
- 5 – 7
drupal_detect_baseurl($file = 'install.php')
Auto detect the base_url with PHP predefined variables.
Parameters
$file The name of the file calling this function so we can strip it out of the URI when generating the base_url.
Return value
The auto-detected $base_url that should be configured in settings.php
Code
includes/install.inc, line 126
<?php
function drupal_detect_baseurl($file = 'install.php') {
global $profile;
$proto = $_SERVER['HTTPS'] ? 'https://' : 'http://';
$host = $_SERVER['SERVER_NAME'];
$port = ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'. $_SERVER['SERVER_PORT']);
$uri = preg_replace("/\?.*/", '', $_SERVER['REQUEST_URI']);
$dir = str_replace("/$file", '', $uri);
return "$proto$host$port$dir";
}
?>Login or register to post comments 