0
我想通过用户IP地址在url中设置国家代码,并用国家代码重写和重定向index2.php
。在url中设置国家代码并用国家代码重写它
的index.php
文件:
<?php
function getLocationInfoByIp(){
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = @$_SERVER['REMOTE_ADDR'];
$result = array('country'=>'', 'city'=>'');
if(filter_var($client, FILTER_VALIDATE_IP)){
$ip = $client;
}elseif(filter_var($forward, FILTER_VALIDATE_IP)){
$ip = $forward;
}else{
$ip = $remote;
}
$ip_data = @json_decode
(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if($ip_data && $ip_data->geoplugin_countryName != null){
$result['country'] = $ip_data->geoplugin_countryCode;
}
return $result;
}
$result = getLocationInfoByIp($_SERVER['REMOTE_ADDR']);
$cont = $result['country'];
?>
的index2.php
文件:
<h1>HELLO WORLD !</h1>
我怎么可以重写URL和index2.php
重定向?
当重定向我的URL应该看起来像orchidkart.com/IN/index2.php
你能送我.htacces s文件关于我的代码.. ?? ..请... –
嘿theres任何一个....帮助我 –