curl 命令遇到重定向时请求重定向后地址

curl HTTP About 499 words

问题

当请求url时得到301重定向的状态码,而非实际重定向后的内容

curl http://www.zhangbj.com

输出

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

解决

查看curl --help后发现可使用-L--location选项追踪重定向后的地址。

$ curl --help
Usage: curl [options...] <url>

 -L, --location      Follow redirects

请求

curl -L http://www.zhangbj.com
Views: 3,802 · Posted: 2020-12-04

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh