zoukankan      html  css  js  c++  java
  • Drupal配置文件settings.php搜索规则

    Drupal的配置文件搜索是通过bootstrap.inc的conf_path()函数实现的:

    function conf_path($require_settings = TRUE, $reset = FALSE) {
      $conf = &drupal_static(__FUNCTION__, '');
    
      if ($conf && !$reset) {
        return $conf;
      }
    
      $confdir = 'sites';
    
      $sites = array();
      if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) {
        // This will overwrite $sites with the desired mappings.
        include(DRUPAL_ROOT . '/' . $confdir . '/sites.php');
      }
    
      $uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
      $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
      for ($i = count($uri) - 1; $i > 0; $i--) {
        for ($j = count($server); $j > 0; $j--) {
          $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
          if (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $sites[$dir])) {
            $dir = $sites[$dir];
          }
          if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir . '/settings.php') || (!$require_settings && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir))) {
            $conf = "$confdir/$dir";
            return $conf;
          }
        }
      }
      $conf = "$confdir/default";
      return $conf;
    }

    例如,对网址http://www.drupal.org:8080/mysite/test/的访问,Drupal会安装下面的顺序搜索配置文件:

    sites/8080.www.drupal.org.mysite.test
    sites/www.drupal.org.mysite.test
    sites/drupal.org.mysite.test
    sites/org.mysite.test
    
    sites/8080.www.drupal.org.mysite
    sites/www.drupal.org.mysite
    sites/drupal.org.mysite
    sites/org.mysite
    
    sites/8080.www.drupal.org
    sites/www.drupal.org
    sites/drupal.org
    sites/org
    
    sites/default

    sites/sites.php可以为站点设置别名。例如可以把访问http://www.drupal.org:8080/mysite/test/的配置文件重定向到example.com/settings.php:

    $sites['8080.www.drupal.org.mysite.test'] = 'example.com';

    参考:

    Multisite - Sharing the same code base

  • 相关阅读:
    PyDev for eclipse 插件下载地址
    Impala SQL 语言元素(翻译)[转载]
    oracle9i-11.2安装包及补丁包下载链接
    oracle link的创建过程
    Oracle 查询历史数据(转帖)
    Alpha、Beta、RC、GA版本的区别
    oracle wm_concat(column)函数的使用
    Quest.Central.for.DB2.v5.0.2.4下载地址
    Hadoop 管理工具HUE配置-初始配置
    maven编译下载源码
  • 原文地址:https://www.cnblogs.com/eastson/p/3351526.html
Copyright © 2011-2022 走看看