htaccess重写语言获取变量ans子目录

时间:2015-09-04 09:54:48

标签: php .htaccess mod-rewrite

我找到了这段代码,它适用于www.mysite.com/fr/或www.mysite.com/fr/login.php:该语言为FR。

 if ($this->filter=='R'){
      $criteria->addBetweenCondition('contractdate',$from, $to, 'AND');
}
else {
    $criteria2 = new CDbCriteria();
    $criteria2->with = 'contracts';
    $criteria2->condition = 'contractdate IS NULL';
    $criteria->addBetweenCondition('schoolstudents.createddate',$from, $to, 'AND');
    $criteria->mergeWith($criteria2);//for filtering based on unregistered students            

但是对于www.mysite.com/fr/directorie/blabla 这不起作用......语言是EN

我的意思是它对子子文件夹不起作用....

1 个答案:

答案 0 :(得分:0)

您可以使用:

#Check for files that do not contain the language string
RewriteCond %{REQUEST_URI} !^/[a-z]{2}/
RewriteCond %{QUERY_STRING} !lang=
RewriteRule ^(.*)$ $1?lang=en [QSA,L]

#Capture the language string and present it as the variable
RewriteRule ^([a-z]{2})/(.*) $2?lang=$1 [QSA,L]