multisite: url redirection based on browser language
-
I’m trying to redirect users who arrive on my main site to a sub-domain depending on their browser language.
I have 2 child themes, one for the main site and one for the sub-domain.
I edited the functions.php file of the child theme used for the main site.`add_action( ‘template_redirect’, ‘custom_lang_found’ );
function custom_lang_found(){
$lang = substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’], 0, 2);
if($lang == “fr” && is_home() {
wp_redirect(‘https://fr.mysite.com’); die();}
}`When I use this code, the condition is_home() seems not to work. I can’t access my WordPress network interface and when I access my main site WordPress interface I am redirected to my sub-domain.
When I go to my main site homepage (my browser is in French), I am redirected to my sub-domain.
For some reasons, Geo Redirect doesn’t work.
- The topic ‘multisite: url redirection based on browser language’ is closed to new replies.