【发布时间】:2021-12-25 14:11:52
【问题描述】:
我需要临时移动我的站点目录,以便可以在域根目录中放入登录页面。登录页面将位于子域并指向根域(通过 DNS)。
我正在尝试通过 htaccess 进行简单的 302 重定向,以将站点目录从 https://example.com/ 更改为 https://example.com/home/,但我陷入了循环。 当我加载网站时,我会永远得到这个......
https://example.com/home/home/home/home/home/home/
任何想法如何让它工作?
Redirect 302 / https://example.com/home/
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
【问题讨论】:
-
您似乎没有移动“您网站的目录”,您只是将主页移动到一个新的 URL - 对吗?但是,如果您重定向主页,您将如何“放入登录页面”?大概你会在那个时候删除重定向?
-
“通过 DNS”到底是什么意思?您是否为此使用了第二个域(或子域)??
-
是的,不要移动网站 - 只需要更改 url。我们通过指向 example.com 的子域/dns 进入登录页面,所以现在我们需要 wordpress 站点出现在 example.com/home
-
只是好奇,如果您在替代主机名上实现登录页面,那么为什么需要重定向现有主页?它们是不同的 URL。
-
当前站点存在于 example.com - 我们需要新的登录页面存在于 example.com - 所以必须移动一些东西......
标签: .htaccess redirect http-status-code-302