The site has three localizations. ru , de and en . English is basic. The user first visits the main page of the site at http://mysite.com/ , sending a request Accept-Language: fr;q=0.9 . Since French is not implemented, it redirects it to the English version http://mysite.com/en/ . The site has a search form that sends a POST request to the URL /search . There is no state saving on the server (sessions and analogues)
I tried to implement via .htaccess , but I don’t know how to correctly implement URL generation for forms and how to transfer a locale. And also how to substitute a locale in the URL, if the user clicks on the link without the http://mysite.com/faq locale
RewriteEngine On #Локаль по умолчанию RewriteCond %{HTTP:Accept-Language} !^(ru|de) [NC] RewriteRule ^$ /en/ [L,R=302] RewriteCond %{HTTP:Accept-Language} ^ru [NC] RewriteRule ^$ /ru/ [L,R=302] RewriteCond %{HTTP:Accept-Language} ^de [NC] RewriteRule ^$ /de/ [L,R=302] #Перенаправлять все запросы на единую точку входа RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php