如何从URL中删除/ Drupal的在Drupal 7时,安装在相应的子目录子目录、安装在、URL、Drupal

2023-09-02 00:42:35 作者:旧照片

在Drupal的6,我能够​​成功的在一个子目录名为Drupal的Drupal的安装,然后引用该网站,而无需使用example.com/drupal。 在Drupal的6到得到这个工作我做了以下内容: - 创建于创建/ Drupal的,其中的根目录下的.htaccess文件。该文件内容为:

In Drupal 6 I was able to successful install Drupal in a subdirectory called drupal and then reference the site without having to use example.com/drupal. In Drupal 6 to get this to work I did the following: - Created an .htaccess file in the root directory where /drupal was created. The file contents was:

Options -Indexes
RewriteEngine On
RewriteRule ^$ drupal/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ drupal/$1

更新了的Drupal /网站/默认/ settings.php文件文件有$ BASE_URL定义为: $ BASE_URL ='http://example.com';

Updated the drupal/sites/default/settings.php file to have the $base_url defined as: $base_url = 'http://example.com';

当我尝试做同样的事情为Drupal 7,只能显示在头版,所有的网页将失败挺可怕的(或只显示头版)。我也曾尝试取消注释在/drupal/.htaccess中的RewriteBase线。首先,我试过的RewriteBase / Drupal的,然后试图的RewriteBase / 。但是,这两个尝试失败。我从来不需要与D6做到这一点,但我想我会排除这种可能的修复程序。

When I try and do the same thing for Drupal 7, only the front page can be displayed, all the pages fail quite horribly (or only display the front page). I have also tried uncommenting the RewriteBase lines in /drupal/.htaccess. First I tried RewriteBase /drupal and then tried RewriteBase /. But both attempts failed. I never needed to do this with D6, but I thought I would rule out this possible fix.

我目前正在测试使用XAMPP(版本1.7.4)下的htdocs的example.com网站上的新的Drupal 7安装(如XAMPP / htdocs中/ example.com / Drupal的)。 Drupal的6个网站是一样的XAMPP安装中,但当然有不同的目录路径(如XAMPP / htdocs中/ d6example.com / Drupal的)。请注意,我也有Drupal的6安装只用$ BASE_URL变量的值改为在生产服务器上运行。

I am currently testing the new Drupal 7 install using xampp (version 1.7.4) with the example.com site under htdocs (i.e. xampp/htdocs/example.com/drupal). The Drupal 6 site is within the same xampp installation, but of course with a different directory path (e.g. xampp/htdocs/d6example.com/drupal). Note that I also have the Drupal 6 installation running on a production server with only the $base_url variable value changed.

那么,你怎么能在一个子目录中安装的Drupal 7,然后从该目录中运行它,而不在URL中具有目录名称? 请注意,我在一个子目录中安装的Drupal 7,因为它允许Drupal的7核心的新版本之间更容易升级。

So, how can you install Drupal 7 in a subdirectory and then run it from that directory without having the directory name in the URL? Note I am installing Drupal 7 in a subdirectory as it allows for easier upgrading between new releases of the Drupal 7 core.

推荐答案

试试这个:

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]

放入example.com目录这个.htaccess文件。 您不必修改drupal7的.htaccess

Put this .htaccess file in example.com directory. You don't have to modify drupal7 .htaccess