# Getting final URL during HTTP redirection

**URL:** <https://www.ruby-forum.com/t/getting-final-url-during-http-redirection/171060>\
**Category:** Ruby\
**Created:** [June 25, 2009, 10:36pm UTC](https://www.ruby-forum.com/t/getting-final-url-during-http-redirection/171060 "2009-06-25T22:36:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ohboyotero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/9dc877/32.png) [@ohboyotero](https://www.ruby-forum.com/u/ohboyotero)\
**Post date:** [June 25, 2009, 10:36pm UTC](https://www.ruby-forum.com/t/getting-final-url-during-http-redirection/171060/1 "2009-06-25T22:36:03Z")

</div>

I need URL resolution for some software I’m working on. Better put, I  
want to figure out the final URL at which you land when requesting some  
initial URL. I have no interest in the page data itself.

Properly handling redirects robustly is difficult due to the horrific  
tendency of many developers and servers to improperly handle them. You’d  
expect a Location header, but I’ve run into several other possible  
responses ranging from Redirect headers to html meta tags.

Is there some library out there that will make my job easier, or will I  
have to roll my own. Keep in mind I want the URL that was last  
requested, not the response from that request.

Thanks!

---

<div class="post-metadata">

**Author:** ![ohboyotero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/9dc877/32.png) [@ohboyotero](https://www.ruby-forum.com/u/ohboyotero)\
**Post date:** [June 25, 2009, 10:46pm UTC](https://www.ruby-forum.com/t/getting-final-url-during-http-redirection/171060/2 "2009-06-25T22:46:15Z")

</div>

What makes this problem even more difficult is that redirects could  
happen on the client side. It’s something that I’ve been looking into  
a lot lately, but no luck yet. I’d be very interested if anybody knows  
of a good solution that could handle this as well.

Michael
