Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


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

curl HTTP 大约 499 字

问题

当请求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
阅读 3548 · 发布于 2020-12-04

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

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

扫描二维码关注我
昵称:
随便看看 换一批