The goal is to add the locale "en" at the beginning of the URLs which doesn't have it.
Example
https://example.com/document/file.php
Becomes
https://example.com/en/document/file.php
The following rule works fine alone:
RewriteCond %{REQUEST_URI} !^/[a-z]{2}/
RewriteRule ^(.*) /en/$1 [R=302,L]
The thing is that I'm stucked in rewriting the URL after the Symfony rules.
Determine the RewriteBase automatically and set it as environment variable.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ RewriteRule ^(.*) - [E=BASE:%1]
Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} . RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Remove app.php from the URL
RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^app_pre_prod\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
Add the requested page to the index (exemple index.php/login)
RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ - [L] RewriteRule ^ %{ENV:BASE}/app.php [L]
The best result I have is: nothing changes.
Or by deactivating the third rule and removing the flag [L]
of the last one, the following result:
https://example.com/en/app.php/document/file.php