简体   繁体   English

从ip检测国家并重定向到相应的国家

[英]Detect country from ip and redirect to according country

I want to redirect the website according to detect country from IP address and redirect it to according country.我想根据从 IP 地址检测到的国家/地区来重定向网站并将其重定向到相应的国家/地区。 ex.前任。 http://www.test.com/in/contact , http://www.test.com/us/contact . http://www.test.com/in/contact , http://www.test.com/us/contact How do I achieve that in laravel ?我如何在 Laravel 中实现这一目标?

Look at this post How to detect language preference in Laravel 5看看这篇文章如何在 Laravel 5 中检测语言偏好
you can get the language form the header with the code below and redirect accordingly您可以使用下面的代码从标题中获取语言并相应地重定向

Request::server('HTTP_ACCEPT_LANGUAGE')

// OR

$request->server('HTTP_ACCEPT_LANGUAGE');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM