in Programming

Redirect your audiences based on country

This is a simple php trick you can use to show customize content for different countries. It uses PHP’s remote_addr variable to capture IP and use ip2location’s database to translate the IP to country. You can download this ip2location sql file to generate your table.

Following code shows how to redirect user from European countries vs rest of the world. You can use more condition to fit your need.


Hope it helps you.