PHP - Redirect depending on specific language

April 2018

Many sites require that you choose the language by clicking on an icon for the country. It is possible to detect the default language of the visitor through the information provided by the browser (languages: $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE']:

if (!isset($Language)) {
$Language = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Language = strtolower(substr(chop($Language[0]),0,2));

Depending on the language of your visitor you can,:
  • The redirect to a specific page:

<? else {
header("Location: /index.php?Language=en");
}  ?>
  • Include a configuration file containing translations of the selected language:

Published by jak58. Latest update on August 7, 2009 at 03:13 PM by jak58.
This document, titled "PHP - Redirect depending on specific language," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
PHP - Detect the display resolution
PHP - Checking the format of an email address