Problama reindirizzamento automatico lingua

Nicky Calo'

Nuovo Utente
20 Gen 2012
9
0
0
Palermo, Italy, Italy
Ciao ragazzi ho implementato questo codice nella mia index per smistare gli utenti in base alla lingua del browser

Codice:
<script language="JavaScript" type="text/javascript">

if (navigator.userLanguage) {theAgent = navigator.userLanguage;}
else {theAgent = navigator.language;}
 if (theAgent.indexOf('en') != -1) {location.href = "home_ing.php";}
 if (theAgent.indexOf('fr') != -1) {location.href = "home_fra.php";}
 if (theAgent.indexOf('de') != -1) {location.href = "home_ted.php";}
 if (theAgent.indexOf('it') != -1) {location.href = "home_ita.php";}

</script>

funziona alla grande TRANNE CHE per gli utenti di tutte le altre lingue (per esempio: ES o NL ecc.) che si trovano davanti una pagina vuota.
Vorrei indirizzare tutti i NON en,fr,de,it sulla pagina in inglese ... come faccio?
 
Codice:
<script>
if (navigator.userLanguage) 
    theAgent = navigator.userLanguage;
else 
    theAgent = navigator.language;

 if (theAgent.indexOf('fr') != -1) location.href = "home_fra.php";
 else if (theAgent.indexOf('de') != -1) location.href = "home_ted.php";
 else if (theAgent.indexOf('it') != -1) location.href = "home_ita.php";
 else location.href = "home_ing.php";

</script>

Ti consiglio di farlo anche o lato server dato che non tutti potrebbero avere il js abilitato
(dai eventualmente un'occhiata a $_SERVER['HTTP_ACCEPT_LANGUAGE'])
 

Discussioni simili