Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当安装在关联的子目录中时,如何从drupal 7中的URL中删除/drupal_Drupal_.htaccess_Drupal 7 - Fatal编程技术网

当安装在关联的子目录中时,如何从drupal 7中的URL中删除/drupal

当安装在关联的子目录中时,如何从drupal 7中的URL中删除/drupal,drupal,.htaccess,drupal-7,Drupal,.htaccess,Drupal 7,在Drupal6中,我能够成功地将Drupal安装到名为Drupal的子目录中,然后引用该站点,而不必使用example.com/Drupal。 在Drupal 6中,为了实现这一点,我执行了以下操作: -在创建/drupal的根目录中创建了一个.htaccess文件。文件内容为: Options -Indexes RewriteEngine On RewriteRule ^$ drupal/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{R

在Drupal6中,我能够成功地将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\u url定义为:
$base\u url='0http://example.com';

当我尝试为Drupal7做同样的事情时,只有首页可以显示,所有的页面都失败得非常可怕(或者只显示首页)。我还尝试在/drupal/.htaccess中取消重写基线的注释。首先我尝试了
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 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目录中。
您不必在Apache服务器上修改drupal7.htaccess,将其添加到root.htaccess文件中

重新启动发动机 重写规则(.*)drupal/$1[L]

更新drupal settings.php文件(在/drupal/site/default/directory中),以便$base_url行显示:

$base_url = 'http://www.example.com';

我在这里回答了一个非常类似的问题: 我对您的问题的回答是相同的,我建议避免使用重写方法,而使用下面描述的虚拟主机方法(这只是我在上面链接中回答的内容的摘录):

。。。 要正确执行此操作,必须首先输入以下行(如果>行已存在,则取消对该行的注释):

接下来,必须创建两个虚拟主机条目。其中一个类似于以下内容:

<VirtualHost *:80>
ServerName your.url.fortheroot
ServerAlias alternate.url.fortheroot
DocumentRoot "/path/to/webroot"
</VirtualHost>

ServerName your.url.fortheroot
ServerAlias alternate.url.fortheroot
DocumentRoot“/path/to/webroot”
下一个条目类似于以下内容

<VirtualHost *:80>
ServerName your.url.forthesubfoldertest
ServerAlias alternate.url.forthesubfolder
DocumentRoot "/path/to/webroot/test"
</VirtualHost>

ServerName your.url.forthesubfoldertest
ServerAlias alternate.url.forthesubfolder
DocumentRoot“/path/to/webroot/test”

但是,在您的情况下,您只需要一个虚拟主机条目&而不是两个

此外,需要注意的是,如果您希望从webroot以外的位置为站点提供服务,那么您还需要

<Directory></Directory>


用于告诉Apache授予访问者什么访问权限的条目(注意:在Linux中,Apache用户应成为文件的所有者[或者,如果您希望避免授予文件所有权,则应在允许Apache用户权限为文件提供服务的方法中设置权限])

不幸的是,上述方法不能与更改$base\u url变量一起使用。事实上,它比我的更糟糕,因为它删除了Drupal主题格式。它对我有效,尝试在这个.htaccess中添加RewriteBase,并在Drupal.htaccess中对其进行注释鉴于这对您有效,我想知道这是否与我的安装或我启用的模块有关。此后,我禁用了pathauto并清除了所有缓存。但这并没有起到任何作用。也许是因为我使用了xampp。因此,RewriteBase/指令实际上将我带到localhost(它反过来又被引导到localhost/xampp/)。我尝试了RewriteBase/example.com,但这也不起作用。我发现真正奇怪的是,所有这些对Drupal6有效,但对Drupal7不起作用。这让我觉得他们改变了一些东西来影响核心的功能。我还应该声明,我有一个不同的站点使用Drupal 6在同一个xampp安装中工作。因此,与不起作用的站点的唯一区别是Drupal 7。请更新您的问题,以添加有关目录/路径结构的详细信息
<Directory></Directory>