Turn off 302 redirect and automatically redirect

I am testing redirects using curl on my localhost. When I run this command:

$curl "test.test.com/landing/0192"

I get this output:

<!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="http://redirect.redirect.com/landing?xid=0192&amp;tt=192">here</a>.</p>
<hr>
<address>Apache/2.2.17 (Fedora) Server at spencervm.adverplex.com Port 80</address>
</body></html>

Now if I run http://redirect.redirect.com/landing?xid=0192&amp;tt=192" I get to me desired destination. So basically all I want to do is turn off the 302 error and redirect to the page it is supposed to redirect to.


Solution 1:

curl doesn't follow redirects by default, but this isn't your web server's problem; HTTP clients are responsible for implementing handling of redirect responses.

Add the -L flag:

curl -L "test.test.com/landing/0192"