I’m making a bilingual website and have this link on each page:
echo "<a href=\\"".$_SERVER['PHP_SELF']."/?lang=ru\\">Switch to Russian</a>";
As you can see, it simply adds a $_GET variable to the end of the current URL. The current page then picks up that variable and switches to the appropriate language.
Additionally, I have the following mod_rewrite:
RewriteEngine On
Options -Indexes
RewriteCond %{http_host} !^www\\.blah\\.com$ [nc]
RewriteRule ^(.*)$ http://www.blah.com/$1 [r=301,nc]
RewriteRule ^([A-Za-z0-9-]+)$ /$1/ [R]
RewriteRule ^([A-Za-z0-9-]+)/$ /$1.php
RewriteRule ^articles/([A-Za-z0-9-]+)$ articles/$1/ [R]
RewriteRule ^articles/([A-Za-z0-9-]+)/$ /article.php?id=$1
The article redirect (/articles/1/ to article.php?id=1) works fine. However, the language switch link doesn’t work on the article page. The above PHP would result in a link to: /articles/1/?lang=ru. Nothing happens when I click the language switch on an article page.
Without the mod_rewrite, I know linking to “article.php?id=1&lang=ru” would work, but how do I do it with the rewrite?
Thanks for any help.