问题原文
原帖链接 · ar099968 · CC BY-SA 3.0
I have build a websites with multiple languages. The URLs look like:
http://www.example.com/en/http://www.example.com/de/
If the user access the main domain http://www.example.com/ the web server detects the user's language (Accept-Language header) and redirects him to one of the above URLs.
Until now we have used a Temporary Redirect (302), because the user can return with other language settings and should then be redirected to the other one.
On another question, which advises to use 307:
307 Temporary Redirect
In this case, the request should be repeated with another URI; however, future requests should still use the original URI. In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request. For instance, a POST request should be repeated using another POST request.
The question is: what is the proper status code for language redirection?
社区高分解答
原帖链接 · Stephen Ostermiller · CC BY-SA 4.0
For users either a 302 or 307 redirect is fine. The only practical difference between those and a 301 redirect is caching. Browsers cache a 301 redirect. If the user changes their browser language settings, it would be better if they were able to visit the root page and redirect differently. So using a non-cachable 302 or 307 redirect is appropriate.
Search engine crawlers don't usually send an Accept-Language header. Rather than issue a redirect when no Accept-Language header is present, you should show a page that has links to all the choices. This will allow links to your root page to pass PageRank to all of your languages. If you instead redirect, all your PageRank will be passed to your default language. Your other languages will be missing out.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
