Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download file with url redirection

I can download a file by url but when I try it from bash I get a html page instead of a file.

How to download file with url redirection (301 Moved Permanently) using curl, wget or something else?

UPD

Headers from the url request.

curl -I http://www.somesite.com/data/file/file.rar

HTTP/1.1 301 Moved Permanently Date: Sat, 07 Dec 2013 10:15:28 GMT Server: Apache/2.2.22 (Ubuntu) X-Powered-By: PHP/5.3.10-1ubuntu3 Location: http://www.somesite.com/files/html/archive.html Vary: Accept-Encoding Content-Type: text/html X-Pad: avoid browser bug 
like image 974
edem Avatar asked Dec 07 '13 11:12

edem


People also ask

What is download redirect?

The Redirect method is the most straight forward of the two, and works by telling the user's browser the location of the file, and it then starts the process of downloading it directly from the server.


1 Answers

Use -L, --location to follow redirects:

$ curl -L http://httpbin.org/redirect/1 
like image 101
deltheil Avatar answered Sep 20 '22 09:09

deltheil