3

Is there an equivalent row to the Wordpress "Home" and "Site"? In otherwords, where can I look in the database to figure out what the domain the site is on? I'm using mysql

4

It can be one or more of the following:

<?php
print $GLOBALS['base_url'];    // Set by drupal_settings_initialize() or settings.php.
print $_SERVER['HTTP_HOST'];   // Set by apache.
print $_SERVER['SERVER_NAME']; // Set by apache.

You can also check the database with this query

SELECT * FROM variable WHERE value LIKE '%example.com%'

where example.com is the domain; this is not guaranteed to be correct though.

  • Interesting. I think the php commands will probably get me what I need. To clarify, the problem I'm trying to solve is that I have numerous Drupal sites set up on the server. I know that the directories that they live in are not correlative to the domains the sites are at. So, I'm trying to figure out how to determine if the sites are live from files and database. (most of the time our default set up doesn't include base_url in the settings file, sad – icicleking May 7 '15 at 0:32
5

I think you're looking for $base_url in /sites/default/settings.php. As far as I know everything in the database works off this value, and it is not explicitly set in the DB

3

There really isn't a perfect analog to wp_options.siteurl & wp_options.home in Drupal. The closest thing is variable.site_frontpage for home path & $base_url in settings.php that contains the site domain URL root.

1

This can be easily evaluated from the code in drupal_settings_initialize() in file includes/bootstrap.inc

As seen in the code below, Drupal first tries to get it from $base_url, if not set then Drupal reads it from $_SERVER['HTTP_HOST']

function drupal_settings_initialize() {

    if (isset($base_url)) {
        // Parse fixed base URL from settings.php.
        $parts = parse_url($base_url);
        ...
    }
    else {
        // Create base URL.
        $http_protocol = $is_https ? 'https' : 'http';
        $base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
        ...
    }

WARNING: Since $_SERVER['HTTP_HOST'] could be easily spoofed using an http request header "Host: something.com", this means you should, I repeat, you should assign a value to $base_url in the settings.php file to avoid the }else{ condition above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.