为什么我的Netlify托管的Gatsby站点301重定向到没有域的路径?

问题描述 投票:1回答:1

我进行了快速检查,以确保我的网站是从301重定向:

https://inlunar.com/news/iceye-shows-off-new-sharp-images-from-satellite

到www。版本:

https://www.inlunar.com/news/iceye-shows-off-new-sharp-images-from-satellite

但是,当我检查时,发现从www发生了额外的301重定向。网址至:

/news/iceye-shows-off-new-sharp-images-from-satellite

没有可在任何地方找到的域名。这是第二次重定向的完整日志:

>>> https://www.inlunar.com/news/iceye-shows-off-new-sharp-images-from-satellite

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Cache-Control:  public, max-age=0, must-revalidate
Content-Type:   text/html; charset=UTF-8
Date:   Wed, 17 Jun 2020 01:09:17 GMT
Etag:   "8af6153ff17d129285674adb734ca0e3-ssl"
Strict-Transport-Security:  max-age=31536000
Age:    0
Server: Netlify
X-NF-Request-ID:    69351fad-bde6-4674-a9b8-fe017a45ee0c-2118676
Location:   /news/iceye-shows-off-new-sharp-images-from-satellite/

为什么这第二个301重定向发生了?

reactjs redirect gatsby netlify
1个回答
0
投票

Netlify似乎正以斜杠重定向到当前请求的位置,与their documentation一致,以提高缓存的命中率。

关于域的省略,仅是a relative URL

相对URL是不包含方案或主机的URL。在 为了被理解,必须将它们与 原始请求。

客户要求http://www.example.com/blog

GET /blog HTTP/1.1
Host: www.example.com

服务器响应:

HTTP/1.1 302 Found
Location: /articles/

该位置的网址由客户端扩展为 http://www.example.com/articles/

© www.soinside.com 2019 - 2024. All rights reserved.