简体   繁体   中英

Website multilingual based on URL Folder and PHP Gettext

So I set up PHP to use Gettext and translate my website /index.php based on the language.

Now I would like to have the URL different for each language ( exemple: mydomain.com/fr/ ). But each folder should point to the main directory and PHP will change the language depending from wiched URL the user is using ( mydomain.com/fr/ or mydomain.com/it/ ).

What is the best way to do it?

It is only up to your imagination (and your regex skills:-B but even I got it and my regex skills are rather weak.)

You could do www.mysite.com/articoli/Sed_ut_perspiciatis_unde_omnis/4711/ for the italian article and www.mysite.com/articles/far_far_way_behind_the_word_mountains/4711/ for the english version of the same article (product)

and you rewrite the first to www.mysite.com/article.php?lang=it?article_id=4711 and the second to www.mysite.com/article.php?lang=en?article_id=4711 (The middle part is discarded - look at ebay ads other pages with categories - they do it like this )

Takes you two regexp rewrites.

Basically you have to think about a structure logical to SEO and intuitive for users wgo sees the url.

This depends also on: what are the most visited pages of your site? I have eg. only 1 php script/page which is responsible for 90% of all web traffic. It used to be 2 (one per german and 1 in english but now I have it "gettext'ed" and now its only one page so much less maintenance.

If SEO optimization is interesting for you - look at similar well known pages and their page /URL structure.

Only rewriting mysite.com/fr/bubalu.html to mysite.com/bubalu.php?lang=fr will be useful only if you have very few pages and I ask myself if this really explains your site structure best to crawlers..

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM