Is there any API and / or function, in PHP, that redirects the pages of my site, according to the locality of the person? Example: If it is not BR, redirect to the English page.
Is there any API and / or function, in PHP, that redirects the pages of my site, according to the locality of the person? Example: If it is not BR, redirect to the English page.
PHP offers a native function for this, take a look at Geo IP Location .
Make sure you have the mod_geoip2 module (GeoIP Extension) installed on your server.
Then change your .htaccess as below:
GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat
# Start Redirecting countries
# Canada
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$
RewriteRule ^(.*)$ http://canada.abcd.com$1 [L]
# India
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^IN$
RewriteRule ^(.*)$ http://india.abcd.com$1 [L]
# etc etc etc...
The official documentation you will find This link