P粉6046694142023-07-29 13:29:04
Try using the following:
SetEnv DEFAULT_LANG en <IfModule mod_rewrite.c> Options +FollowSymLinks -Indexes RewriteEngine On RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{HTTP_HOST} ^([a-z]{2})\.([a-z0-9-]+\.[a-z]+)$ [NC] RewriteRule .* - [QSA,E=LANGUAGE:%1] RewriteCond %{ENV:LANGUAGE} ^$ RewriteRule .* - [QSA,E=LANGUAGE:en] RewriteCond %{QUERY_STRING} !language= RewriteRule ^(.*)$ ?language=%{ENV:LANGUAGE} [QSA] RewriteCond %{REQUEST_URI} !^/public RewriteRule ^(.*)$ /public/?language=%{ENV:LANGUAGE} [L,QSA] </IfModule>
Using the above, language detection should work properly even when redirecting to files under the public folder. The %{ENV:LANGUAGE} variable will remain unchanged throughout the rewrite, so the correct language parameters should be passed to the file in the public folder.