I have a multilingual website (English / Hungarian). I need to redirect my domain (mysite.hu) to subdirectories (/hu, /en), based on chosen user language preference (the default is Hungarian). For example:

Sometimes my 301 redirection looks like this:

user types: mysite.hu ---> redirected to --> mysite.hu/hu

and sometimes it looks like this:

user types: mysite.hu ---> redirected to --> mysite.hu/en

(the domain - mysite.hu - never used in standalone, redirection is automatically applied every time)

I think it's very confusing in an SEO aspect because this way I 301 redirect my main page permanently to two different pages at the same time. Or this is the proper way to do this? What is the best way to do this in an SEO friendly way?


2 Answers 2


the most SEO friendly way to redirect

The most SEO friendly way is probably not to redirect at all - unless perhaps the user has already made a specific choice (during their session).

...they get the Hungarian site by default.

Search engines need to be able to crawl both versions - so they cannot be forced (defaulted) to one or the other.

You need to make sure you have implemented the appropriate HREFLANG tags so the search engines know about the different language versions. See Googles' help docs: https://support.google.com/webmasters/answer/189077?hl=en

I 301 redirect my main page permanently to two different pages at the same time.

This isn't a "permanent" redirect. Users can presumably change their mind (or a different user uses the same computer/browser) etc. So, if a user has already made a choice then a temporary (302, 303 or 307) would be more appropriate.

If a user follows a result in the SERPs for example.hu/en then they should not be redirected, even if their language preferences are set otherwise.

UPDATE: From comments, it would seem that:

  1. The current language redirect only occurs on the document root. ie. example.com/. Other URLs are not redirected.
  2. example.com/ and example.com/hu would otherwise contain the same content.
  3. The document root example.com/ is not considered a canonical URL (it doesn't appear in the sitemap).

From this I think a 302 (temporary) redirect is perfectly OK. I would a avoid a 301 (permanent) simply because you don't necessarily want users to cache the redirect.

  • 1.) "is probably not to redirect at all" Yes, but then I will get duplicates: the root domain and the preferred language subfolder (for ex: mysite.hu and mysite.hu/hu ) which is exactly the same by default. Duplicates aren't evil? :) 2.) They can crawl both English pages and Hungarian pages (language changer do-follow links are presented many places in my site) plus there is an XML sitemap with the full list of URLs/pages in different languages (language indicators included)
    – Catso
    Commented Jan 29, 2019 at 18:03
  • 3.) yes, but when a user changes his mind (and language) there won't be a mysite.hu and any redirection. He will change from mysite.hu/hu to mysite.hu/en or back ( there is no redirection here ). Only if someone types in the root domain (mysite.hu) that can be redirected in 2 different languages, based on previous (cookie stored) preferences. If you have chosen English once, next time the root domain will redirect you to the English subfolder instantly. So basically the root domain doesn't exist, or at least can't be used
    – Catso
    Commented Jan 29, 2019 at 18:03
  • But Maybe I just generated a problem, from where no problems to be found :)
    – Catso
    Commented Jan 29, 2019 at 18:03
  • Ah, so you only redirect the document root, which would otherwise be a duplicate of /hu? And URLs of the form /foo/bar are not redirected, even if /hu/foo/bar might exist? (Consequently /foo/bar results in a 404, when /hu/foo/bar exists?)
    – MrWhite
    Commented Jan 30, 2019 at 10:56
  • Yes, exactly. /foo/bar will give a ( helpful ) 404 page, even if /hu/foo/bar is exists.
    – Catso
    Commented Jan 30, 2019 at 11:06

The domain www.hp.com automatically redirects to your region-specific subfolder based on your IP address. It could also be done using accept-language in htaccess.

So, for instance, if you are located in Germany, hp.com redirects to hp.com/de-de/ via a 301 redirection.

Only the root domain www.hp.com redirects to a region-specific subfolder.

I changed the user-agent of my firefox browser to the Googlebot user agent and visited hp.com while connected from germany, It still redirected to the German subfolder.

So, I guess that when Googlebot visits hp.com it is automatically redirected to hp.com/us-en/ since googlebot has an American IP address.

Then, at the bottom of the HP.com/us-en/ there is a country selector with links to every region-specific hp.com subfolders.

At last, I have checked if it was easy to find hp.com pages on google search. I typed "hp drucker" (hp printer in german) while in the USA. The three first links were from www.hp.com, 1 to the American subfolder /us-en/ and 2 to the german subfolder /de-de/

So, I think this technique works pretty well!

In your case, I would suggest to redirect mysite.hu based on the language of the browser using accept-language in HTACCESS. So, if someone has a browser with hungarian language in it, this visitor will be redirect to the hungarian subfolder /hu and if the language is english it will be redirected to /en

Googlebot does not have accept-language in his HTTP request, so it will be redirected from mysite.com to mysite.com/hu. It is not a problem for crawling the english version as long as mysite.com/hu is linked to mysite.com/en

#if request to robots.txt no redirection
RewriteCond %{REQUEST_URI} ^robots.txt$
RewriteRule ^ - [L]

#if lang is en then redirect to /en
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP:Accept-Language} en [NC]
RewriteRule ^ /en [R=301,L]

#Otherwise redirection from root domain to the default hu
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ /hu [R=301,L]

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.