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

Why would my site redirect back to the same page but with a trailing slash on the URL?

· 52CE 我爱测

I'm working on a website that is new to me and I'm trying to make sure there is not practical reason why the site has been set up the way it is before I change it. Many pages have been set up with 301 redirects to the same page e…

问题原文

原帖链接 · MRawcliffe · CC BY-SA 4.0

I'm working on a website that is new to me and I'm trying to make sure there is not practical reason why the site has been set up the way it is before I change it.

Many pages have been set up with 301 redirects to the same page except with an / add at the end. This is something that I normally manage in Google Analytics, so I'm not sure why 301s were used.

Is there any reason to do this? If not, is it worth it to fix? Shouldn't there be a negative effect on SEO to have 301 redirects this way? They are also using canonical links - it all seems conflicting and I could just combine the data in GA instead.

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

It is very common practice to choose a preferred URL for each page and to redirect to the preferred form. The practice is known as "URL canonoicalization". This is good practice because:

  • The redirects help SEO. It makes the site more consistent and more crawlable. It consolidates link juice value for a page to a single URL.
  • The redirects make analytics cleaner. You don't get multiple URLs for the same page appearing in reports

It sounds like the chosen preferred form of URLs on your site includes a trailing slash. I would normally recommend recommend choosing the version without the trailing slash as the preferred URL because it is simpler. See Does it make a difference if your URL path ends in a trailing slash or not? However, if your site uses the trailing slash already, you shouldn't change it.

When you link to other pages on your site, you should always make sure the links use the preferred form and include the trailing slash. When you link to the preferred form consistently, most users and crawlers will never need to encounter the redirect at all.

Canonical tags serve some of the same purpose of these redirects. They let search engines know which URL is the preferred one. It is possible to rely solely on canonical tags and not issue redirects, however redirects are usually better than canonical tags:

  • Redirects are a stronger signal to search engine than canonical tags. Google often ignores canonical tags and chooses a non-preferred URL to index. It almost never does that with redirects.
  • Redirects are developer and Q/A visible. It is usually easier to detect problems with redirects than with canonical URLs that are hidden until you view the page source.
  • Redirects are user visible. When using redirects to canonicalize URLs, users will be far more likely to bookmark and link to your canonical URLs.

Even if you do use redirects to canonicalize URLs, it still often makes sense to include canonical tags in pages. Canonical tags and redirects are not incompatible. You just need to make sure the canonical tag is not pointing to a URL that redirects. You still might want to include the canonical tag because:

  • It is hard to find every variation of a URL to redirect. URLs may vary in protocol, host name, sub-domain, case sensitivity, trailing slash, default document name, spelling, punctuation, query parameters, or even hash fragments. You may check for some of those and redirect for some of them, but it is difficult to find and redirect every possible variation.
  • In some cases, multiple URLs for the same content is desired. Canonical tags can let search engines know about URL variations even when you can't redirect without breaking functionality:
    • Tracking parameters on the URL that don't change the page content but are important for analytics. Google Analytics commonly uses such utm parameters.
    • Development and staging servers that host the same content but which are needed for making and testing changes.
    • Users may expect to be able to get the same content over multiple protocols such as HTTP vs HTTPS.
  • Canonical tags help prevent malicious third parties from easily copying your whole site using a reverse proxy and stealing search engine traffic.

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

资料来源与适用范围

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

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

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