PHP redirect based on geolocation for word press

  • kratos-2012
  • Born
  • Born
  • kratos-2012
  • Posts: 1

Post 3+ Months Ago

I need to find a simple php script to add to my wordpress start page to redirect visitors based on geo-location.

I'm a newbie so I am looking for a tutorial or any guidance.

Thanks!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

You would need an IP database and check for the user's location by determining the user's IP address.

PHP Code: [ Select ]
// Retrieving the correct IP Address
if(!empty($_SERVER['HTTP_CLIENT_IP']))
{
    $ip = $_SERVER['HTTP_CLIENT_IP'];
}
elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
    $ip = $_SERVER['REMOTE_ADDR'];
}
  1. // Retrieving the correct IP Address
  2. if(!empty($_SERVER['HTTP_CLIENT_IP']))
  3. {
  4.     $ip = $_SERVER['HTTP_CLIENT_IP'];
  5. }
  6. elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  7. {
  8.     $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  9. }
  10. else
  11. {
  12.     $ip = $_SERVER['REMOTE_ADDR'];
  13. }
  • googlecentos
  • Born
  • Born
  • googlecentos
  • Posts: 4
  • Loc: usa

Post 3+ Months Ago

there are a plugin "WordPress Geo IP Redirect"

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.