Php 在地理位置上更改域,保持URL不变
我正在使用此脚本根据用户的IP重定向用户。 但问题是它重定向到主页,或者只重定向到我在脚本中指定的URL。我怎样才能在保持URL不变的情况下更改域?例如,site.com/whateverpage重定向到site.au/whateverpagePhp 在地理位置上更改域,保持URL不变,php,redirect,geoip,Php,Redirect,Geoip,我正在使用此脚本根据用户的IP重定向用户。 但问题是它重定向到主页,或者只重定向到我在脚本中指定的URL。我怎样才能在保持URL不变的情况下更改域?例如,site.com/whateverpage重定向到site.au/whateverpage <?php // Next two lines are for Beyond Hosting // Don't forget to change your-domain require_once '/home/your-domain/php/Net
<?php
// Next two lines are for Beyond Hosting
// Don't forget to change your-domain
require_once '/home/your-domain/php/Net/GeoIP.php';
$geoip = Net_GeoIP::getInstance('/home/your-domain/php/Net/GeoIP.dat');
// Next two lines are for HostGator
require_once 'Net/GeoIP.php';
$geoip = Net_GeoIP::getInstance('GeoIP.dat');
try {
$country = $geoip->lookupCountryCode($_SERVER['REMOTE_ADDR']);
switch((string)$country) {
case 'AU':
$url = "http://www.site.au";
break;
case 'CA':
$url = "http://www.site.ca";
break;
default:
$url = "http://site.com";
}
if (strpos("http://$_SERVER[HTTP_HOST]", $url) === false)
{
header('Location: '.$url);
}
} catch (Exception $e) {
// Handle exception
}
?>
将$\u服务器['REQUEST\u URI']
添加到重定向中
header("Location: $url/$_SERVER[REQUEST_URI]");
标题('Location:'.$url/$\u服务器['REQUEST\u URI']);是这样吗?