Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess htaccess-子目录上的域重定向-缺少子目录名称_.htaccess_Redirect_Subdirectory - Fatal编程技术网

.htaccess htaccess-子目录上的域重定向-缺少子目录名称

.htaccess htaccess-子目录上的域重定向-缺少子目录名称,.htaccess,redirect,subdirectory,.htaccess,Redirect,Subdirectory,我有几个域名。我想将它们全部重定向到主域 RewriteCond %{HTTP_HOST} ^example\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule ^(.*)$ "https\:\/\/target\.net\/$1" [R=301,L] 子目录.htaccess设置用于虚拟路由(在index.php文件中处理),如下所示: Options -MultiViews RewriteOptions

我有几个域名。我想将它们全部重定向到主域

RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ "https\:\/\/target\.net\/$1" [R=301,L]
子目录
.htaccess
设置用于虚拟路由(在
index.php
文件中处理),如下所示:

Options -MultiViews

RewriteOptions InheritBefore
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
但子目录名称在重定向过程中未“传递”。例如:

example.com/thedir/2020/x/y/z 将重定向到: target.net/2020/x/y/z

为什么呢


多亏了

停止使用动态配置文件,它们增加了复杂性,非常容易出错,而且会降低http服务器的运行速度。相反,在它们所属的地方实施这些规则:进入http服务器的主机配置。@arkascha你的意思是这个问题没有具体的简单解决方案吗?使用真正的http服务器配置比使用多个动态配置文件更容易。@arkascha好的,但如果仍然如此,这是我拥有的系统,我现在想做尽可能少的更改?这些规则中没有任何东西可以“吞下”路径中的文件夹。重定向到https时的反斜杠没有任何意义,但这不是问题所在。您是否已经在http主机的
DOCUMENT\u ROOT
文件夹中实现了第一条规则(重定向到https),而不是在子文件夹中?这可以解释你所描述的。从你的问题来看,事情不清楚。我建议您在问题中添加文件夹/文件层次结构。