HTTP Status code for language redirect

后端 未结 5 1709
青春惊慌失措
青春惊慌失措 2020-12-25 13:43

I wonder which HTTP Status code I should have to send in language redirects.

I have the following php code to redirect via HTTP headers to most important language in

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-25 14:23

    You could serve every language under the same url and then use content-negotiation of the Accept-Language header, but I wouldn't recommend that.

    I would rather suggest that on your web sites root url, you issue a redirect (303 - See Other) to a language sub page (E.g. /en). When you do that, respond with a Vary header, that specifies Accept-Language (And any other relevant headers, such as Cookie). That way, any intermediaries (proxies, caches) will be able to cache the response. I would specifically not issue a 301, since you still want links to point to the root url. On the language-specific page, I would put a rel="canonical" to the root url.

    See also these threads:

    • How does Google treat HTTP response 303?
    • Canonical URLs and Content Negotiation

提交回复
热议问题