【curl-error】curl で302 Found The document has moved の原因
curl で302 Found The document has moved の原因
curl で Web サーバ上のファイルを取得しようとしたところ次のエラーが発生しました。
302 Found
Found
The document has moved
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="(URI)">here</a>.</p>
</body></html>
エラーの原因
様々な原因が考えられると思います。
今回は http から https へのリダイレクトが原因でした。
そのサイトは https (TLS,ポート443)が標準化されており、http (ポート80) へ接続された通信は https へ転送されていました。
これが原因でした。
実際に "The document has moved "、要するにドキュメントはここに移動されたで https への URI が記載されていました。
解決方法
curl.exe の実態確認
curl.exe のフルパスを確認します。Windowsデフォルトが利用されていることを確認します。
C:\>which curl.exe
C:\WINDOWS\system32\curl.exe