2015-09-04 82 views
-2

我發現這個代碼,它的工作原理是www.mysite.com/fr/或www.mysite.com/fr/login.php:語言是FR。htaccess重寫語言獲取變量和子目錄

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

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

但www.mysite.com/fr/directorie/blabla 這不工作...的語言是EN

我的意思是它不爲子子工作.. ..

+0

你試過我的答案......與子工作 – Croises

回答

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]