apache - 使用 .htaccess 重定向

标签 apache .htaccess http-status-code-302

我想将所有用户页面请求重定向到同一域上的页面。

例如,我有一个“正在 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/

相关文章:

php - 将一页重定向到 http 而不是 https

html - 如何拒绝对 Assets 的访问

javascript - 导航的事件类

.htaccess - SEO - 可能与 301 永久移动有关的问题

Android 客户端登录身份验证 - HTTPURLConnect

php - 将 php session 移动到 redis。有可能不丢失现有 session 数据吗?

apache - 在 Apache Ace 和管理代理之间启用 SSL 身份验证

Apache mod_rewrite 使用 302 而不是 https 重定向到 http

java - 我如何在没有 Tomcat 的情况下在 Apache 2.2 上运行 Java 应用程序?

未加载 PHP 配置文件? (Mac OS X 优胜美地)