【问题标题】:How to set the base url in drupal如何在drupal中设置基本网址
【发布时间】:2011-08-18 06:17:57
【问题描述】:

我可以在哪里设置 drupal 站点的基本 URL。目前,当我在本地主机中访问该站点时,它会重定向到原始站点。请帮帮我。

我尝试在 sites/default/settings.php 中设置 $base_url

这是我设置基本网址的部分

/**
 * Base URL (optional).
 *
 * If you are experiencing issues with different site domains,
 * uncomment the Base URL statement below (remove the leading hash sign)
 * and fill in the URL to your Drupal installation.
 *
 * You might also want to force users to use a given domain.
 * See the .htaccess file for more information.
 *
 * Examples:
 *   $base_url = 'http://www.example.com';
 *   $base_url = 'http://www.example.com:8888';
 *   $base_url = 'http://www.example.com/drupal';
 *   $base_url = 'https://www.example.com:8888/drupal';
 *
 * It is not allowed to have a trailing slash; Drupal will add it
 * for you.
 */
# $base_url = 'http://www.example.com';  // NO trailing slash!
$base_url = 'http://localhost/mysite';  // NO trailing slash!

【问题讨论】:

    标签: drupal base-url


    【解决方案1】:

    通常你不需要设置base_url, 您只需清除 drupal 缓存

    【讨论】:

    • 更具体地说,“用于清除缓存和重建路由表的 PHP 文件”部分对我有用!!!
    【解决方案2】:

    settings.php

    $base_url = 'http://baseurl.com';
    

    编辑 您在我发布此内容时进行了编辑。您可以将settings.php 文件的部分粘贴到您正在设置的位置吗?你确定在settings.php 的其他地方没有设置其他$base_url 吗?

    【讨论】:

    • 嗨大卫,最初它没有在 settings.php 中设置我已将代码粘贴到我的问题中
    • 好的,谢谢。你能再解释一下吗?你怎么知道没有设置?是什么导致您出现问题?
    • 我以前从未遇到过这样的问题。我已将内容从服务器下载到我的本地主机并导出数据库。在settings.php 中设置数据库之后,我尝试在本地主机中访问该站点。但它会重定向到原始站点。所以我终于在设置中设置了基本 url 变量,这是可选的。数据库中是否有任何设置。例如在 wordpress 中,我们必须更改数据库中的 home 和 site url 才能访问网站。
    【解决方案3】:

    在将数据库从远程服务器恢复到本地主机后,我遇到了类似的问题,事实证明这是由“移动工具”引起的,它在安装时劫持了我的站点的重定向。在备份或导出数据库之前禁用它可以解决问题。只是发帖以防有人遇到这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      • 1970-01-01
      • 2015-12-31
      • 2015-12-26
      • 1970-01-01
      相关资源
      最近更新 更多