当安装位于关联的子目录中时,如何从 Drupal 7 中的 URL 中删除/drupal [英] How to remove /drupal from URL in Drupal 7 when installation is in the associated sub-directory

查看:22
本文介绍了当安装位于关联的子目录中时,如何从 Drupal 7 中的 URL 中删除/drupal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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/sites/default/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 站点(即 xampp/htdocs/example.com/drupal)测试新的 Drupal 7 安装.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]

将此 .htaccess 文件放在 example.com 目录中.不用修改drupal7 .htaccess

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

这篇关于当安装位于关联的子目录中时,如何从 Drupal 7 中的 URL 中删除/drupal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆