Forum Moderators: phranque
<a href="<? echo $_SERVER[PHP_SELF] . "?lang=en"; ?>"><img src="images/en_flag.gif" border=0></a> RewriteRule ^(([^/]+/)*[^/.]+)$ index.php?page=$1 [L]
<?php
if ($_SESSION[lang] == "") {
$_SESSION[lang] = "en";
$currLang = "en";
} else {
$currLang = $_GET[lang];
$_SESSION[lang] = $currLang;
}
switch($currLang) {
case "en":
define("CHARSET","ISO-8859-1");
define("LANGCODE", "en");
break;
case "de":
define("CHARSET","ISO-8859-1");
define("LANGCODE", "de");
break;
default:
define("CHARSET","ISO-8859-1");
define("LANGCODE", "en");
break;
}
header("Content-Type: text/html;charset=".CHARSET);
header("Content-Language: ".LANGCODE);
?>
[edited by: phranque at 12:56 am (utc) on Aug 2, 2013]
[edit reason] Please Use Example.com [webmasterworld.com] [/edit]
If the folder type URL is implemented you MUST alter the PHP script so that it also returns a 404 HEADER and error message for ALL URLs requested with a non-valid language code.
I'm not sure about making the language "folder" optional. This makes the pattern ambiguous and is a Duplicate Content problem in the making (if e.g. /en/ and "no folder" return identical content).
[edited by: phranque at 12:57 am (utc) on Aug 2, 2013]
[edit reason] Please Use Example.com [webmasterworld.com] [/edit]
[edited by: phranque at 12:58 am (utc) on Aug 2, 2013]
[edit reason] unlinked & exemplified url [/edit]