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
Apache 在子文件夹中运行Drupal-停止访问URL example.com/subfolder/index.php_Apache_.htaccess_Drupal 7 - Fatal编程技术网

Apache 在子文件夹中运行Drupal-停止访问URL example.com/subfolder/index.php

Apache 在子文件夹中运行Drupal-停止访问URL example.com/subfolder/index.php,apache,.htaccess,drupal-7,Apache,.htaccess,Drupal 7,出于与此站点主机相关的各种原因,我们在子文件夹“live”中运行Drupal 7站点,因此到D7的路径是/home/username/public_html/live/ 为了从子文件夹中加载Drupal 7站点,我们在/home/username/public_html中使用了下面的.htaccess,它非常有效 RewriteEngine on RewriteRule ^$ live/index.php [L] RewriteCond %{DOCUMENT_ROOT}/live%{REQUES

出于与此站点主机相关的各种原因,我们在子文件夹“live”中运行Drupal 7站点,因此到D7的路径是/home/username/public_html/live/

为了从子文件夹中加载Drupal 7站点,我们在/home/username/public_html中使用了下面的.htaccess,它非常有效

RewriteEngine on
RewriteRule ^$ live/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/live%{REQUEST_URI} -f
RewriteRule .* live/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* live/index.php?q=$0 [L,QSA]
但是,如果我键入,则会加载站点主页,并且位置栏中的URL不会屏蔽到。以前的一个不同重写规则的问题导致其他访问者访问了此页面,这导致我们的Google Analytics统计数据中包含了此问题


有没有办法重写.htaccess规则以避免从现在开始可见?位于/home/username/public\u html/live的.htaccess是默认的D7.htaccess。

答案是在/live文件夹中添加另一个.htaccess文件:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s+\/live/index\.php\s+ [NC]
    RewriteRule ^ https://%{HTTP_HOST} [L,R=301]
</IfModule>

重新启动发动机
RewriteCond%{THE_REQUEST}^[A-Z]{3,}\s+\/live/index\.php\s+[NC]
重写规则^https://%{HTTP_HOST}[L,R=301]

使用RewriteCond检查原始请求URI,如果是
/live/index.php
,则进行外部重定向。感谢您的回答。你能解释一下这些规则会是什么样子吗?我没有htaccess的经验。你看过手册吗?@CBroe给出了答案,你应该能够找到你需要的东西。