我想在我的网站上使用 Clean URL htaccess
这是 SEO 的重要 URL,如何更改我的 URL
http://www.mysite.com/?do=change&lang=en to http://www.mysite.com/en/
文件functions.php
include './lang/choose.lang.php';
function Browser_Lang(){
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
switch ($lang){
case 'ar': // Arabic
return 'ar';
break;
default: // English for other languages
return 'en';
break;
}
}
文件选择.lang.php
if($_REQUEST['do'] == 'change'){
$lang = Secure($_GET['lang']);
Set_Cookie('language',$lang,time()+(3600*24*30*12));
}
if(isset($_COOKIE['language'])){
$lang = Read_Cookie('language');
}else if(!isset($_COOKIE['language']) && isset($_SERVER['REMOTE_ADDR'])){
$lang = Browser_Lang();
}else{
$lang = 'en';
}
switch ($lang){
case 'ar': // Arabic
include 'ar.lang.php';
break;
default: // English for other languages
include 'en.lang.php';
break;
}