首页 > 解决方案 > htaccess - 子目录上的域重定向 - 缺少子目录名称

问题描述

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

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

这是为什么?

谢谢

标签: .htaccessredirectsubdirectory

解决方案


推荐阅读