Jump to content

Visitors Redirection ???


algeriano

Recommended Posts

Hello,

 

I want to ask you how to redirect a user according to his browser language..i want to redirect users according to their browsers language to either french or english and not only this i want to redirect them too to a translated template with specific language for exemple if a french visitor comes to my sites it will be redirected to whmcs french with a template too translated in french and if he is an english visitor he will be redirected to english whmcs with english template

 

how can i do it please?

Link to comment
Share on other sites

You could try with something like this:

$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($language ){
   case "en":
       header("Location: index.php?language=english");
       break;
   case "fr":
       header("Location: index.php?language=french");
       break;
   case "it":
       header("Location: index.php?language=italian");
       break;        
   default:
       // Here i set the default language
       header("Location: index.php?language=english");
       break;
}

But i would go for a while cycle between all active languages on WHMCS so that when you add/remove languages you don't have to update the script because it's all dynamic. Anyway this file should be included in the header.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated