redirect - 不使用-v则不显示301 curl

标签 redirect curl http-status-code-301

我正在查看几个2.level域用来重定向到其www 3.level域的301,例如,我认为单凭 curl 就足够了

curl  myvote.io
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.myvote.io/">here</A>.
</BODY></HTML>

但是,我必须使用curl -v来获取另一个域上的任何输出:
curl -v evitaochel.com
* Rebuilt URL to: evitaochel.com/
* Hostname was NOT found in DNS cache
*   Trying 62.116.130.8...
* Connected to evitaochel.com (62.116.130.8) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: evitaochel.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Mon, 13 Oct 2014 16:18:02 GMT
* Server Apache is not blacklisted
< Server: Apache
< Location: http://www.evitaochel.com
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8 
<
* Connection #0 to host evitaochel.com left intact

如果有的话,我期望myvote.io是一个更奇怪的地方,
curl -v myvore.io
* Rebuilt URL to: myvote.io/
* Hostname was NOT found in DNS cache
*   Trying 216.239.36.21...
* Connected to myvote.io (216.239.36.21) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: myvote.io
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: http://www.myvote.io/
< Date: Mon, 13 Oct 2014 16:30:40 GMT
< Content-Type: text/html; charset=UTF-8
* Server ghs is not blacklisted
< Server: ghs
< Content-Length: 218
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Alternate-Protocol: 80:quic,p=0.01
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.myvote.io/">here</A>.
</BODY></HTML>
* Connection #0 to host myvote.io left intact

显示它包括一些扩展,由ghs提供,我想是Google。任何想法可能是什么原因,并且如果原因始终在“curl -v”中可见,或者可能是某些隐藏的配置?

最佳答案

curl在不带任何选项的情况下不显示任何响应 header ,这就是它的工作方式。使用-v甚至-i只能看到标题。

重定向页面(301、302或其他任何内容)可以包含主体,但也可以不包含主体。这取决于站点。

由于您获得了HTTP重定向,因此您可能也想使用-L来使curl跟随它们。

关于redirect - 不使用-v则不显示301 curl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26344760/

相关文章:

c - Linux | C 中的 Shell 实现 |重定向文件包括提示

wordpress - anchor 标记中的onclick和href重定向

php - 带有 PHP Curl 的 FTPS 获取部分下载

ios - 页面 curl 过渡在动画结束时挂起的可能原因是什么?

wordpress - 安全地将旧的 Wordpress 博客链接重定向到新的 WP 博客

redirect - CloudKit 仪表板一直显示登录屏幕

grails - 从Grails “after”过滤器访问重定向ID

shell - 在命令行上将密码传递给 curl

.htaccess - 想要将域重定向到子文件夹中的博客,直到完整站点启动

django - 我无法更新 Django 的 RedirectView。它一直引用状态为 301 Moved Permenantly 的旧 URL