Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a 302 redirection URL's Location header in PHP?

I am trying to find a universal way to expand most if not all of the shortened URLs out there. I know short URLs such as bit.ly, TinyURL, goo.gl, etc use the 302 redirection method to redirect you to another site. How can I make a HEAD request to the shortened URL in php and get the "Location" part of the header?

Please help me with this.

Thanks

like image 776
QAH Avatar asked Nov 15 '25 02:11

QAH


1 Answers

Forget it everyone. :) With some internet searching, I found this:

expanding short url to original url using PHP and CURL — Hasin Hayder

It shows me exactly how to do this.

like image 187
QAH Avatar answered Nov 17 '25 16:11

QAH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!