1

我正在尝试在我的 .htaccess 文件中添加一条规则,以便如果我要更改我的网站,它会在用户尝试访问我的网站时将其重定向到“正在建设中”页面。

我在用着:

# SITE UNDER CONSTRUCTION REDIRECT
Redirect 302 / http://redsquirrelsoftware.co.uk/construction.html

但这随后将我发送到http://redsquirrelsoftware.co.uk/construction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.html我显然得到了 404 错误。

如何停止网址上的递归尾部?

4

2 回答 2

1

Redirect是一个mod_alias不能与指令混合的mod_rewrite指令,所以为了防止循环,你应该只使用这样的 mod_rewrite 指令:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !construction\.html   [NC]
RewriteCond %{REQUEST_URI} !folder_to_exclude    [NC]
RewriteRule .*           /construction.html      [R=301,L]

这个答案假设/construction.html页面在同一个域中。如果不是,请替换:

RewriteRule .*             /construction.html         [R=301,L]

RewriteRule .*   http://new_domain/construction.html  [R=301,L]
于 2013-03-04T17:08:07.320 回答
0

尝试使用前提条件:

RewriteCond %{REQUEST_URI} !^/construction.html
Redirect 302 / http://redsquirrelsoftware.co.uk/construction.html
于 2013-03-04T16:59:19.673 回答