Redirecting to a page into the if condition
-
Dears,
I am trying to redirect visitors following some conditions. First, if they are in pages 34, 41, 78 or 90, I don’t want anything to happens. But if they are not, I want that visitors are redirected: 1) to page 34 if they are from some countries; 2) to page 78 if they are in any of the others.
Here is the following code I am using. All parts are working properly, but the redirecting options:
<?php wp_reset_query(); require_once('geoip.inc'); $gi = geoip_open('GeoIP.dat', GEOIP_MEMORY_CACHE); $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); $my_countries = array('br','pt','ao','cv','gw','mz','st','tl'); if (!is_page(array(34,41,78,90))) { if (!in_array(strtolower($country), $my_countries)) { header('Location: https://www.example78.com'); } else { wp_redirect('https://www.example34.com', 301); } } ?>
Any help will be very much appreciated!!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Redirecting to a page into the if condition’ is closed to new replies.