【问题标题】:IP redirect while showing message显示消息时进行 IP 重定向
【发布时间】:2013-11-11 22:50:53
【问题描述】:

我有一个想法,它有点复杂,我不知道如何去做。
例如,
我想将 123.456.789.10 从 http://mywebsite.com 重定向到 http://google.com
有一个像 http://mywebsite.com/messages/go_away.html 这样的临时页面先显示大约 5-10
秒然后有那个页面自动将他们重定向到http://google.com
因此他们会在自动重定向之前看到消息 5-10 秒。

keep in mind i may want to add more than 1 IP address or range like this.
xxx.xxx.
xxx.xxx.
xxx.xxx.
and so on.

xxx.xxx。将是第一组 2 组数字我该怎么做?
提前致谢,

【问题讨论】:

  • 123.456.789.10.11.12 是什么意思?
  • 这些是第一组 2 组 IP 地址,例如。 xxx.xxx.xxx.xxx 但我只想使用前 2 个。

标签: regex apache .htaccess mod-rewrite redirect


【解决方案1】:

第 1 步: 在您的 DOCUMENT_ROOT/.htaccess 文件中使用此规则:

RewriteEngine On

RewriteCond %{REMOTE_ADDR} !^(123\.456\.|789\.10|11\.12)
RewriteRule !^temp-page /temp-page.html [L,NC,R]

第 2 步:

然后在/temp-page.html 内部使用这样的代码:

<meta http-equiv="refresh" content="5; url=http://www.google.com/">
<h1>This temporary page will redirect to www.google.com in 5 seconds</h1>

【讨论】:

    【解决方案2】:

    您可以像这样使用Meta refresh

    <meta http-equiv="refresh" content="10; url=http://google.com/">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-29
      • 2017-07-06
      • 2022-07-18
      相关资源
      最近更新 更多