如何按国家/地区更改WHMCS网址

时间:2017-05-16 10:27:56

标签: php .htaccess whmcs whmcs-invoice-template

我是whmcs的新手,我想按国家/地区更改网址。

如果来自印度的客户有以下网址: - http://example.com/in/或来自英国的网址有http://example.com/uk/这样的网址。

我正在尝试此.htaccess文件,但它无效。

RewriteEngine on
RewriteRule ^in/(.*).php?(.*) /$1.php&country=india [NC,L,QSA] 

我也想根据国家/地区更改主页。

1 个答案:

答案 0 :(得分:1)

更好的方法是从用户IP地址获取国家/地区。

使用此PHP函数找到here

// Get user IP
if (isset($_SERVER['HTTP_CLIENT_IP'])){
    $ip = $_SERVER['HTTP_CLIENT_IP'];
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
    $ip = $_SERVER['REMOTE_ADDR'];
}

$user_country_code = ip_info($ip, "Country Code"); // This will be a country code e.g 'IN', 'US'


// Redirect to Location
header('Location:' . "https://example.com/" . $user_country_code);
die();
相关问题