Is there a way to redirect people from a page on my .com website to a corresponding page on my website if they are in the UK


I’m hoping for a bit of help or to be pointed in the right direction!

I have three websites:

  1. a website for the UK
  2. a .ie website for Ireland
  3. a .com website
    for everyone else

The .com was my main site, and people in Ireland and the UK are used to visiting it, but now I need them to go to their local site, where the content has been tailored for them.

I host on WP Engine and have the GeoTarget add-on. For the past year, I’ve been using the code below to redirect everyone, but it’s a bit blunt. It sends everyone to the home page of their local site, even if they were trying to access a specific page e.g. ‘services’.

    function country_geo_redirect() {
    if ( is_user_logged_in() ) {

    $country = getenv('HTTP_GEOIP_COUNTRY_CODE');
    if ( $country == "GB" ) {
    wp_redirect( '', 301 );
    } else if ( $country == "IE" ) {
    wp_redirect( '', 301 );
    add_action('init', 'country_geo_redirect');

It would be much better if I could edit this and redirect them to a page corresponding to the one they tried to visit e.g. if they tried to visit services, I should redirect them to the services page on the .ie or

Any ideas?

Blackrath 1 month 2023-01-01T12:07:15-05:00 0 Answers 0 views 0

Leave an answer