【问题标题】:Using htaccess to redirect .nl to .com/nl使用 htaccess 将 .nl 重定向到 .com/nl
【发布时间】:2014-04-03 09:11:48
【问题描述】:

我想通过使用 htaccess 文件将在地址栏中使用国家/地区代码的用户重定向到正确的子页面。

例如: www.example.nl 重定向到: www.example.com/nl

有什么建议吗?

【问题讨论】:

标签: .htaccess redirect


【解决方案1】:

我建议您使用GeoIP 服务 [PHP] 找出访问者所在的国家/地区,然后进行重定向。

include("geoipcity.inc");
include("geoipregionvars.php");

$gi = geoip_open("/usr/local/share/GeoIP/GeoIPCity.dat",GEOIP_STANDARD);
$getcountry = geoip_record_by_addr($gi,$_SERVER['REMOTE_ADDR']);

if ( $getcountry->country_code == "NL" ) {
    header('Location: www.example.com/nl');
}

像这样的 NL 重定向

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-24
    • 2016-11-17
    • 1970-01-01
    • 2015-01-27
    • 1970-01-01
    • 1970-01-01
    • 2013-06-13
    • 2016-06-18
    相关资源
    最近更新 更多