How can I redirect foreigners by IP to other URL in WordPress?

You could try using:

http://ipinfodb.com/ip_location_api.php

Send a get with the incoming ip adress and based on the response redirect it to a different part of your website.

$request = new WP_Http;
$result = $request->request( 'http://api.ipinfodb.com/v3/ip-country/?key=<your_api_key>&ip=74.125.45.100' );

I hope this helps.