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

I found this code and it's working for www.mysite.com/fr/ or www.mysite.com/fr/login.php : the language is FR.

#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]

But for www.mysite.com/fr/directorie/blabla This doesn't work... The language is EN

I mean it doesn't work for sub-subfolder....

You can use:

#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]