B
B
BonBon Slick2021-06-22 16:06:08
Search Engine Optimization
BonBon Slick, 2021-06-22 16:06:08

Place locale in header or URL?

I ran into the issue again, earlier I decided to sculpt the locale in the URL, but I noticed that then it is necessary to localize, sculpt the locale in 99% of API links. Why?
Trite validation and server response, not just localized entities. For example links

host.com/ru-ru/api/v1/login
host.com/ru-ru/api/v1/register
host.com/ru-ru/api/v1/update/profile

and other POST / PUT / PATCH must be localized, not just GET requests.
Indeed, in case of errors on the server during registration, they must also be localized. For example, "password is too short".
But this creates a certain inconvenience to sculpt the locale into a yurl instead of a header.

https://symfony.com/doc/current/translation/locale...
Since you can store the locale of the user in the session, it may be tempting to use the same URL to display a resource in different languages ​​based on the user's locale. For example, www.example.com/contact could show content in English for one user and French for another user. Unfortunately, this violates a fundamental rule of the Web: that a particular URL returns the same resource regardless of the user. To further muddy the problem, which version of the content would be indexed by search engines?

A better policy is to include the locale in the URL using the special _locale parameter:


If this approach is more correct and better for SEO, then why use headers? For example Content-Language(en, de ...) and Accept-Language (en-us, de, ...) or custom X-Locale types (en-us...)

Or even use sub domains?

When and which approach to choose, why? What is best for SEO?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2021-06-22
@BonBonSlick

It's api he doesn't give a shit about seo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question