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]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.