大网数据广告活动
网站运营与故障问答

Proper status code for language redirection (301, 302, … 307)?

· 52CE 我爱测

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 (Acc…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。