I am working on a multilingual website (php/mysql) and my question is what would be the best solution for language identification - sessions/cookies or URI identification. I mean in terms of SEO, what would be more accurate.
Thanks
I am working on a multilingual website (php/mysql) and my question is what would be the best solution for language identification - sessions/cookies or URI identification. I mean in terms of SEO, what would be more accurate.
Thanks
There are different types of projects which shouldn't use the same language implementation.
Let me give some examples:
The first project has an single domain name, let's say example.com. This website, should be available in three languages. In order to let the search engine clearly crawl and index each language - the correct solution here would be passing it by url. example.com/fr/ for french.
The second project, has an domain name for each language, example.fr, example.co.uk. It would be best that each domain is only indexed by the search engine by it's primary language. Therefor, the solution I'd pick would be storing the language in a cookie when switching. (or redirect to the other domain entirely).
If we'd pick the solution of example 1 for example 2, both example.co.uk/fr/ and example.fr would have the same content, which isn't SEO friendly.
If you put the language into the URI a webcrawler can index the site in its different languages and users are able to bookmark/link to them. This is not possible, if there is no direct reference (=> URL) to the pages.
You can combine both ways: If no language specific information available within the URI, try to find it out from a cookie/session, and if this one fails, look at the Accept-Language
-Header. Now, if one user change the language (by link or whatever) write it into a cookie (for later visits).
URL. You can use something like a '/en/' prefix to all paths. Obviously you'd use mod_rewrite or appropriate framework routing config.
Using only sessions/cookies, it wouldn't really be possible for someone to link straight to the 'Swahili' version of your content. Instead, you would have a default language (English?) which all incoming links would point to. Once there, if a user wanted your content in Mandarin then they could choose that option, but they won't get it straight out of the gate so using URI identification is my personal pick.
There are a couple of ways to tag what language to use in the URI, either by setting up some sort of directory structure, such as: http://domain.tld/localized/fr/
for the main page of the french content, or you can abstract it out in your database and identify the language through GET
variables: http://domain.tld/?l=4
for the main page of language with ID of 4
Or, as Wesley van Opdorp pointed out, you can set up a separate domain or sub-domain for each language: http://domain.fr
or http://fr.domain.tld
As far as SEO goes, I believe the best way would be to adhere to the Top Level Domain Standards and set up a separate domain for each language you want to host the site in (http://domain.fr
, http://domain.ru
, etc). This of course would mean purchasing more domains, so if that isn't an option my second choice would be to set up sub-domains for each langauge such as in: http://fr.domain.tld
and http://ru.domain.tld