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

Should I use 301 or 302 for location-based redirects?

· 52CE 我爱测

I'm setting up geo-redirects for my site and am unsure which redirect type to use. I've read many articles on this subject, but still do not have a clear answer. Here's the plan: Visitor lands on our homepage: https://example.com…

问题原文

原帖链接 · Brian Kidwell · CC BY-SA 3.0

I'm setting up geo-redirects for my site and am unsure which redirect type to use. I've read many articles on this subject, but still do not have a clear answer.

Here's the plan:

  1. Visitor lands on our homepage: https://example.com
  2. System recognizes user's IP location
  3. 301 or 302 redirect? <--- not sure which one
  4. User lands on the correct page (/en-us in USA, /en-ca in Canada, /en-au in Australia, etc.)

Step 3 is where I'm confused. I know I need to redirect them, but is a 301 redirect or 302 redirect better in this case?

I'd like to rank each of these pages in their specific countries / cities. To provide some more context, check out http://specialized.com. If you search for "Specialized bikes" in Google, specialized.com ranks as number one. If you land on it you are automatically redirected to the appropriate location. However, if you search for "specialized bikes australia" then specialized.com/au/en-au/ is the page that ranks... no redirection needed. This is the same setup I'm looking for.

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

As Stephen points out in comments, geo-IP redirects are generally bad for SEO (it prohibits the site from being crawled naturally and can at times hinder users through being redirected incorrectly). However, specialized bikes would appear to get around the SEO issues with sitemaps containing the different language versions (hreflang). (And only redirecting when no locale is included in the URL.)

301 or 302 redirect?

The referenced site would appear to use a 301 (permanent) redirect. 301s are cached hard by the browser. Once redirected; always redirected (from cache). This can result in marginally less traffic from repeat visitors.

However, I would tend to go for a 302 (temporary) redirect - which is not cached - for the following reasons:

  • A 301 is a one-way trip. If you needed to change your geo-ip-redirect-logic then it's a struggle. Users who have already visited your site might still get redirected the old way.

  • Users are not necessarily stationary. Mobile/tablet/laptop users can travel between regions, but a 301 redirect can tie them to the first region in which they visited the site.
    A geo-IP redirect is not necessarily permanent.

A 302 would not suffer these "problems" (albeit "edge cases").

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

资料来源与适用范围

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

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

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