【问题标题】:Redirect Users from China (based on IP) to a specific URL将来自中国的用户(基于 IP)重定向到特定 URL
【发布时间】:2017-02-07 02:56:25
【问题描述】:

我在 AWS 的 apache 服务器上有一个 wordpress 站点。如果用户的 IP 来自中国,我想将用户重定向到特定的 url。我的问题是:

  1. 在哪里设置此重定向?我正在考虑的选项是:调整 apache 配置文件,或在 wordpress 应用程序中编辑某些 php 文件,或安装一些 wordpress 插件。
  2. 我如何知道用户的 IP 是否来自中国使用代码?我可以在互联网上逐个查找单个 IP 以对其进行地理定位,但如何在运行时确定?

谢谢!

【问题讨论】:

    标签: wordpress apache redirect ip


    【解决方案1】:

    请安装IP2Location Apache 模块

    更新.htaccess文件如下:

    RewriteEngine On
    RewriteCond %{ENV:IP2LOCATION_COUNTRY_SHORT} ^CN$
    RewriteRule ^(.*)$ http://www.redirecturl.com [L]
    

    【讨论】:

      猜你喜欢
      • 2015-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-24
      • 2015-07-31
      • 1970-01-01
      • 2017-09-09
      相关资源
      最近更新 更多