我想将所有用户页面请求重定向到同一域上的页面。
例如,我有一个“正在 build 中,BRB”页面,我希望所有用户在尝试访问网站上的任何页面时都能看到该页面。
我尝试使用这个:
Redirect 302 / http://www.domain.com/index2.php
它的作用是尝试将重定向应用到index2.php页面,它会陷入一个循环,用户然后会看到这个,直到浏览器停止。
http://www.domain.com/index2.phpindex2.phpindex2.phpindex2.php etc., etc,
关于如何将该规则写入除该页面之外的任何想法?
最佳答案
您必须排除要重定向到的文件。这是 mod_rewrite 的示例:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule !^index2\.php$ /index2.php [L,R=302]
</IfModule>
关于apache - 使用 .htaccess 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/744087/