【问题标题】:Bypass Geo Redirect for specific directories绕过特定目录的地理重定向
【发布时间】:2015-06-04 16:18:02
【问题描述】:

我正在尝试绕过我网站中特定网址的重定向。想知道是否有人可以提供帮助。

下面的代码是我使用的代码,原始网址替换为example.com

我希望能够在不发生重定向的情况下访问http://example.com/admin

有没有办法做到这一点,还有没有办法使用你自己的 IP 做到这一点?

    function country_geo_redirect()
{

    $country = getenv('HTTP_GEOIP_COUNTRY_CODE');
    if ($country == "US" ) {
        wp_redirect("http://usa.example.com/");
        exit;
    }
    else if ($country == "GB" )
    {
        wp_redirect("http://uk.example.com/");
        exit;
    }
}
add_action('init', 'country_geo_redirect');

【问题讨论】:

    标签: php wordpress .htaccess redirect geolocation


    【解决方案1】:

    如果服务器找到您的 IP 地址,您可以绕过重定向代码。

    if IP address == <my ip address> then
     ' do nothing here
    else
      country_georedirect()
    end if
    

    【讨论】:

    • 有没有办法在全球范围内普遍应用这一点,而不仅仅是 IP?
    • 您可以使用key=password等特殊参数绕过地理定位功能。在这种情况下,只要在 URL 参数中输入密码,就可以访问管理页面。
    猜你喜欢
    • 1970-01-01
    • 2019-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多