Reputation: 1201
I have a php based web application in which I want to redirect user to sub domain based on their country such as nz, au, in etc.
What is the best way to do that?
Htaccess? PHP? JavaScript?
How can I do with the above options?
Or you guys can suggest any other way as well!
Upvotes: 1
Views: 147
Reputation: 3833
Something like this (Pseudo code!):
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE}
RewriteRule ^(.*)$ https://example.com/$1 [L]
Upvotes: 0
Reputation: 776
Please! check this out:
and there is more such way which is helpful.
Edit
Reference:
Code:
<?php
$meta = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?
ip='.$_SERVER['REMOTE_ADDR']));
if($meta['geoplugin_countryCode']=='IT')
{
}
?>
For more details:
Upvotes: 1