Home ›
Getting the current domain in a Drupal siteGetting the current domain in a Drupal site
Submitted by Benjamin Melançon on August 1, 2007 - 10:52am
drupal get url base
My way:
$url = $_SERVER['HTTP_REFERER']
$domain = parse_url($url, PHP_URL_HOST);
if(substr($domain, 0, 4) == 'www.') $domain = substr($domain, 4);
Used in the Agaric recipe profile for setting the files system location.
The way settings.php did it:
if (isset($_SERVER['HTTP_HOST'])) {
$domain = '.'. preg_replace('`^www.`', '', $_SERVER['HTTP_HOST']);
drupal get url base
My way:
$url = $_SERVER['HTTP_REFERER']
$domain = parse_url($url, PHP_URL_HOST);
if(substr($domain, 0, 4) == 'www.') $domain = substr($domain, 4);
Used in the Agaric recipe profile for setting the files system location.
The way settings.php did it:
if (isset($_SERVER['HTTP_HOST'])) {
$domain = '.'. preg_replace('`^www.`', '', $_SERVER['HTTP_HOST']);
Comments
Why are you using the
Why are you using the HTTP_REFERER key to detect the domain?
Post new comment