HTTP Status code for language redirect

后端 未结 5 1690
青春惊慌失措
青春惊慌失措 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条回答
  • 2020-12-25 14:07

    Possibly HTTP 300 "Multiple Choices" as it's technically the same data/document but available in multiple languages?

    0 讨论(0)
  • 2020-12-25 14:16

    HTTP 303, because it have the most suitable formulation - See Other (302-Moved Temporarily and 301 - Moved Permanently). Actually HTTP 303 response in this situation to ensure that the web user's browser can then safely refresh the server response without causing the initial HTTP POST request to be resubmitted.

    0 讨论(0)
  • 2020-12-25 14:19

    Google uses 302 Found for redirection to localised page.

    I think it is safe if Google uses it...

    However, it's always good to check what selected response should do and what it is intended for and does it affect caching:

    http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

    0 讨论(0)
  • 2020-12-25 14:19

    I think the questions is more related what you want to achieve:

    1: Your index page should be the landing page for your visitor, and you want that page the be indexed by search engines.

    Pros: You have one entry page for all your visitors that can host additional information before the actual landing page. However, it will not have content for a specific language.

    Cons: You don't have any content pages for all languages on search engines.

    2: The actual translated page should be the landing page, and if possible your visitors should end up at the translated page directly if that is possible. The redirect page is only for visitors that ended up straight at your site by entering hostname in the addressbar.

    Pros: You have multiple "landing pages" for each individual language, which helps scoring and clickthrough.

    Cons: You don't have a generic landing page.

    There are more pros and cons on these two choices, but I can't think of it right now.

    If option 1: use a 302 because you still want it to be part of search index. if option 2: use a 301 because you don't want that page to be indexed. Alternatively, use a noindex on the language select page.

    Afaik, Google only takes into account, 301, 302 and 307 (temporary maintenance), and I think it consider everything else as 302 (seems most logical). As far as the browser goes, I think it doesn't matter. It might affect caching, but I think nowadays they are pretty aggressive in caching even 3xx responses.

    0 讨论(0)
  • 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
    0 讨论(0)
提交回复
热议问题