It is very much possible. Below is a short program that will include the correct document based on the language setting of the browser. Below are also some heavy comments to guide you through the process. It might be confusing here and there. Just go to php.net and look at the manual for the functions I used. Or just reply back here and I'll try to clarify more on what I did.
<?php
$browser = explode(",", $HTTP_ACCEPT_LANGUAGE);
/ $HTTP_ACCEPT_LANGUAGE is a server predefined variable. It stores what languages the users browser is enabled for. I believe the first one is the "default language" meaning, that's the language it will use first if "Automatic Detection" is enabled in the users browser (Or in another term, it's what the user prefers.). The explode() splits the $HTTP_ACCEPT_LANGUAGE value where there is a comma. The values are then assigned into their own array. So, say the person visiting knows English, French, and Spanish and the visitor sets their browser in that order (Also note, the user prefers English). The value in $HTTP_ACCEPT_LANGUAGE would be "en,fr,sp". explode() would then split that string into three arrays because I set explode to split strings wherever there is a comma. Now since the user has one major preference "English", The $browser[0] array contains the string "en". This variable is then passed to the switch function below. switch() is like a bunch of branched off if() statments. /
switch($browser[0])
{
/ Below I used strings as the case instead of numbers. switch will match up whatever value in $browser[0] is to the correct document. Back to the example of the English speaking visitor. Since the value in $browser[0] is "en" the switch statment branches off to "case: 'en'". Thus the english document would be included into the file (There is no redirection needed.) The "break;" statement just ends that block of coding. "default:" is just any other value that doesn't match. For example if $browser[0] was "de", there is no other matching "de" case. So it would go down to default. /
case 'en':
include("english.html");
break;
case 'fr':
include("french.html");
break;
case 'sp':
include("spanish.html");
break;
default:
print("Error there is no document by that language.");
}
?>
PHP can be a very powerful tool. The above program is in fact very small and quick (just look at it without the comments I have). This program can be the index page on your website. When a visitor, that speaks French, comes to the site. The french.html home page loads in automatically. There is no redirection needed. You can do many things to the index page. Another example is if you have a default layout design of the site. This page can contain the default layout of the homepage then, you would just need to load in the correct text and graphics.