Php 如何按国家更改WHMCS url

Php 如何按国家更改WHMCS url,php,.htaccess,whmcs,whmcs-invoice-template,Php,.htaccess,Whmcs,Whmcs Invoice Template,我是whmcs的新手,我想按国家更改URL 如果来自印度的客户的URL类似:-http://example.com/in/或来自英国的URL,如http://example.com/uk/ 我正在尝试此.htaccess文件,但它不起作用 RewriteEngine on RewriteRule ^in/(.*).php?(.*) /$1.php&country=india [NC,L,QSA] 另外,我想根据国家更改主页。更好的方法是从用户IP地址获取国家 使用此PHP函数可以找到

我是whmcs的新手,我想按国家更改URL

如果来自印度的客户的URL类似:-
http://example.com/in/
或来自英国的URL,如
http://example.com/uk/

我正在尝试此
.htaccess
文件,但它不起作用

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

另外,我想根据国家更改主页。

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

使用此PHP函数可以找到:


感谢您的回答,但我以前尝试过此代码。htaccess但不起作用propely@jhon尝试将此代码添加到
index.php
文件的顶部我使用的是whmcs not corephp@jhon尝试将此代码添加到
编辑模板/*您的活动模板*/homepage.tpl
// 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();