For the past few days I've been stuck with creating a PHP-based multilingual website. I've tried a great deal of solutions but had no luck so far.
This is how I would like my URL's to look:
http://www.example.com/en/about
http://www.example.com/cs/o-nas
etc.
I've been using this rewrite rule BEFORE I decided to implement multilingual support and it worked just fine:
RewriteBase /kittytea/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)$ ?page=$1 [L]
My links look like this:
<a href="about">
Has anyone got an idea how to add the multilingual support? I'm familiar with passing URL parameters using the GET method.
I might add that I'm using a simple PHP SWITCH statement for loading individual website sections.
PS - It's a very small website and I don't need a top notch solution. I just want to make it work :)
Thanks!
You can try including the 2 letter language code as part of the rewrite:
RewriteBase /kittytea/
# with language
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]{2})/([a-zA-Z0-9_-]+)$ ?lang=$1&page=$2 [L]
# original, without language
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)$ ?page=$1 [L]
Your php script would then need to check for the 2 letter language code in the lang
parameter and return the appropriate content.
Then you'd need to change your links to:
<a href="en/about">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.