I am hoping for a little bit of assist or to be pointed in the best path!
I’ve three web sites:
- a .co.uk web site for the UK
- a .ie web site for Eire
- a .com web site
for everybody else
The .com was my essential website, and folks in Eire and the UK are used to visiting it, however now I want them to go to their native website, the place the content material has been tailor-made for them.
I host on WP Engine and have the GeoTarget add-on. For the previous 12 months, I have been utilizing the code beneath to redirect everybody, however it is a bit blunt. It sends everybody to the house web page of their native website, even when they have been attempting to entry a particular web page e.g. ‘companies’.
perform country_geo_redirect() {
if ( is_user_logged_in() ) {
return;
}
$nation = getenv('HTTP_GEOIP_COUNTRY_CODE');
if ( $nation == "GB" ) {
wp_redirect( 'https://www.uk-website.co.uk', 301 );
exit;
} else if ( $nation == "IE" ) {
wp_redirect( 'https://www.irish-website.ie', 301 );
exit;
}
}
add_action('init', 'country_geo_redirect');
It might be significantly better if I might edit this and redirect them to a web page similar to the one they tried to go to e.g. in the event that they tried to go to companies, I ought to redirect them to the companies web page on the .ie or .co.uk
Any concepts?