Suppose I have a bash script that goes through a file that contains a list of old URLs that have all been redirected.
curl --location http://destination.com will process a page by following a redirect. However, I’m interested not in the content, but on where the redirect points so that I can update my records.
What is the command-line option for curl to output what that new location for the URL is?
You wou want to leave out the
--location/-Lflag, and use-w, checking theredirect_urlvariable.curl -w "%{redirect_url}" http://someurl.comshould do it.Used in a script:
From the curl man page: