-2

Hello I'm trying to make redirections in wordpress for example if I have ip starting on 73.... I want to redirect to subpage. How and where can I do it? I have to use .htaccess file?

marcin.g
  • 365
  • 1
  • 2
  • 14
  • 1
    what ip are you referring to ? –  May 19 '14 at 20:27
  • I will have diffrent ip from diffrent cities and If I have ip from London I want to redirect to subpage for London. – marcin.g May 19 '14 at 20:29
  • its called geolocation, not very reliable. http://stackoverflow.com/questions/10562265/i-want-to-find-current-location-of-user-in-php/ (and many more) –  May 19 '14 at 20:30
  • This might help: http://www.wpjedi.com/geo-redirect-wordpress-plugins-for-geo-targeting/ – anubhava May 19 '14 at 20:33

1 Answers1

1

The code below is basic and will work sometimes, but users can spoof their IP address if they want to.

$userIp = explode('.', $_SERVER['REMOTE_ADDR']);

if (($userIp[0].'.'.$userIp[1].'.'.$userIp[2]) == '192.168.2') 
{
header("location:sub.domain.com");
}
dcclassics
  • 896
  • 1
  • 12
  • 38