[英]What is the best way to redirect user to sub-domain(au, nz etc) based on country?
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.我有一个基于 php 的 Web 应用程序,我想在其中根据用户的国家/地区(例如 nz、au、in 等)将用户重定向到子域。
What is the best way to do that?最好的方法是什么?
Htaccess?访问? PHP? PHP? JavaScript? JavaScript?
How can I do with the above options?我该如何处理上述选项?
Or you guys can suggest any other way as well!或者你们也可以建议任何其他方式!
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:更多细节:
Something like this (Pseudo code!):像这样(伪代码!):
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE}
RewriteRule ^(.*)$ https://example.com/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.