0

I have a website that offers ten UI languages. The root (https://example.com/) redirects via htaccess to subfolders (https://example.com/en https://example.com/de etc.) depending on the user's browser settings (Accept-Language) like this:

RewriteCond %{HTTP:Accept-Language} (de) [NC]
RewriteRule ^$ /de [R,L]
RewriteCond %{HTTP:Accept-Language} (en) [NC]
RewriteRule ^$ /en [R,L]
RewriteCond %{HTTP:Accept-Language} (es) [NC]
RewriteRule ^$ /es [R,L]
RewriteCond %{HTTP:Accept-Language} (fr) [NC]
RewriteRule ^$ /fr [R,L]
RewriteCond %{HTTP:Accept-Language} (it) [NC]
RewriteRule ^$ /it [R,L]
RewriteCond %{HTTP:Accept-Language} (nl) [NC]
RewriteRule ^$ /nl [R,L]
RewriteCond %{HTTP:Accept-Language} (pt) [NC]
RewriteRule ^$ /pt [R,L]
RewriteCond %{HTTP:Accept-Language} (pl) [NC]
RewriteRule ^$ /pl [R,L]
RewriteCond %{HTTP:Accept-Language} (ru) [NC]
RewriteRule ^$ /ru [R,L]
RewriteCond %{HTTP:Accept-Language} (tr) [NC]
RewriteRule ^$ /tr [R,L]

Two questions:

  1. Am I shooting myself in the knee regarding SEO using this approach?
  2. If the accept-language does match any of the ones I test, I want the redirect to /en. How would I achieve this?
1
  • "If the accept-language does match any of the ones I test" - Presumably you mean "does not match"?
    – MrWhite
    Apr 2 at 18:07

1 Answer 1

1

From a SEO perspective you do not need this at all. Search engines will just detect the different languages of your pages based on content or lang-tag and prefer those in the search results. You can implement hreflang to assist with the matching, but in your case it would mainly be used to distribute PageRank more evenly accross the different languages, which can also be a good thing. Hreflang however is absolutely nessesary if you target multiple countries/regions with the same language e.g. en-US, en-GB, en-AU.

In addition your solution uses cachable redirects, which would prevent the user from navigating back to the original page, even after changing the language of the browser. Condidional redirects should always be implemented using non cachable HTTP status codes (e.g. 302, 303).

From a usability perspective you should consider where your users come from when accessing the pages. It is quite likely, that they understand multiple languages and a German user might understand English quite well, even though the Accept-Language header indicates only German. In this case a redirect will add latency and anchors will be lost if they were present in the original links, which can cause users to bounce. Personally I think it is a way better solution to provide a language switcher element on the website whenever the Accept-Language header indicates that the current language might not be the perfect fit. This language switcher should of course show the best possible fit at the top.

If you implement hreflang in addition you can also implement a x-default URL (e.g. https://example.com/default) that is used for all non matching languages.

1
  • Thanks for that. I will then revert this to my original version, where I scan through the Accept-Languages (through header) of the browser and redirect the visitor to the language folder that matches first. Users can, of course, always change the language on the website to whatever they want if they are unhappy with the auto-detected language. Apr 3 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.