在 Drupal 6 中,我能够在名为 drupal 的子目录中成功安装 Drupal,然后引用该站点,而无需使用 example.com/drupal。
在 Drupal 6 中,为了使其正常工作,我执行了以下操作:
- 在创建 /drupal 的根目录中创建了 .htaccess 文件。文件内容是:
Options -Indexes
RewriteEngine On
RewriteRule ^$ drupal/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ drupal/$1
更新了drupal/sites/default/settings.php
文件将 $base_url 定义为:$base_url = 'http://example.com';
当我尝试对 Drupal 7 做同样的事情时,只能显示首页,所有页面都失败得非常可怕(或者只显示首页)。我还尝试取消注释 /drupal/.htaccess 中的 RewriteBase 行。首先我尝试过RewriteBase /drupal
然后尝试RewriteBase /
。但两次尝试都失败了。我从来不需要对 D6 执行此操作,但我想我会排除这种可能的修复。
我目前正在使用 xampp(版本 1.7.4)和 htdocs 下的 example.com 站点(即 xampp/htdocs/example.com/drupal)测试新的 Drupal 7 安装。 Drupal 6 站点位于相同的 xampp 安装中,但当然具有不同的目录路径(例如 xampp/htdocs/d6example.com/drupal)。请注意,我还在生产服务器上运行了 Drupal 6 安装,仅更改了 $base_url 变量值。
那么,如何在子目录中安装 Drupal 7,然后从该目录运行它,而无需在 URL 中包含目录名称呢?
注意我将 Drupal 7 安装在子目录中,因为它允许在 Drupal 7 核心的新版本之间更轻松地升级。
尝试用这个:
RewriteEngine On
RewriteBase /example.com
RewriteRule ^$ drupal/ [L]
# rewrite rules for drupal files
RewriteCond %{DOCUMENT_ROOT}/example.com/drupal/$1 -f
RewriteRule ^(.*)$ drupal/$1 [L,QSA]
# rewrite rules for drupal paths
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ drupal/index.php?q=$1 [L,QSA]
将此 .htaccess 文件放在 example.com 目录中。
您不必修改 drupal7 .htaccess
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)