Put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2})/(.+)$ /foreign/$1?lang=$1 [L,NC,QSA]
Question
I have a multilingual website. So I need to do something like this:
for example my site is: example.com
and it has 2 foreign languages (en & de). Now i wanna install my site on example.com/foreign
and if someone opens example.com/en/*anything*
i want my website to open example.com/foreign/*anything*
WITHOUT ANY REDIRECTION and also it should pass a parameter like LANG via POST or GET or anything else to detect the tables of database which are related to that language.
And the main problem is that *anything*
can be anything like a directory name or something like test.php?par1=value1&par2=value2
so what's the solution for this?
La solution
Put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2})/(.+)$ /foreign/$1?lang=$1 [L,NC,QSA]