0

We had different index pages for different states of users.

    let my site is some www.example.com

So if user is requesting from Andhra Pradesh state then he needs to load apindex.php. If he is from Tamilnadu then he needs to load tamilindex.php. How can I accomplish this? Is it possible to identify users request on server side so that we can redirect to required page or else we have to handle it in client side? I am new to this redirection, any approach to do this redirection.

Thanks in advance.

Jenz
  • 8,280
  • 7
  • 44
  • 77
Sekhar Babu
  • 368
  • 2
  • 8
  • 27
  • When they first enter your site ask them which state they come from and load accordingly? – AyB Feb 06 '14 at 05:38
  • Looks like this is already answered [here](http://stackoverflow.com/questions/7766978/geo-location-based-on-ip-address-php) – Sunil Kumar Feb 06 '14 at 05:41

2 Answers2

1

With php you can achieve

use this API http://ipinfo.io

function ip_details($IPaddress) 
{
    $json       = file_get_contents("http://ipinfo.io/{$IPaddress}");
    $details    = json_decode($json);
    return $details;
}

$IPaddress  =   $_SERVER['REMOTE_ADDR'];

$details    =   ip_details("$IPaddress");

//echo $details->city;   #Tamilnadu  
//echo $details->country;  
//echo $details->org;      
//echo $details->hostname; 

header('location: http://'.$details->city.'.index.com'); 
Dimag Kharab
  • 4,439
  • 1
  • 24
  • 45
0

we can achieve this by php script and third party application to check state on basis of IP. by using that we can redirect user to particular index page.

Geo Location based on IP Address - PHP

http://css-tricks.com/snippets/php/detect-location-by-ip/

Community
  • 1
  • 1
Jignesh Patel
  • 1,028
  • 6
  • 10