# Redirected URL

**URL:** <https://www.ruby-forum.com/t/redirected-url/174181>\
**Category:** Ruby\
**Created:** [August 22, 2009, 12:57am UTC](https://www.ruby-forum.com/t/redirected-url/174181 "2009-08-22T00:57:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![novicetoruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@novicetoruby](https://www.ruby-forum.com/u/novicetoruby)\
**Post date:** [August 22, 2009, 12:57am UTC](https://www.ruby-forum.com/t/redirected-url/174181/1 "2009-08-22T00:57:42Z")

</div>

Hi,  
I was trying to parse a web page where multiple hyper links exist.  
Each hyper link redirecting to a different server. I just want store  
first server it is redirecting the request too.

I tried using ‘net/http’ to capture ‘Location’ from response. But not  
working. Showing ‘Location’ value as blank.

Please help.  
Thanks,  
Anil.

---

<div class="post-metadata">

**Author:** ![novicetoruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@novicetoruby](https://www.ruby-forum.com/u/novicetoruby)\
**Post date:** [August 22, 2009, 3:27am UTC](https://www.ruby-forum.com/t/redirected-url/174181/2 "2009-08-22T03:27:31Z")

</div>

Anil K. wrote:

> Hi,  
> I was trying to parse a web page where multiple hyper links exist.  
> Each hyper link redirecting to a different server. I just want store  
> first server it is redirecting the request too.
> 
> I tried using ‘net/http’ to capture ‘Location’ from response. But not  
> working. Showing ‘Location’ value as blank.

Do you know the difference between:

1. parsing a web page and retrieving the first link’s href

and

1. examining a response’s Location header

> **[URL redirection](https://en.wikipedia.org/wiki/URL_redirection)**
>
> URL redirection, also called URL forwarding, is a World Wide Web technique for making a web page available under more than one URL address. When a web browser attempts to open a URL that has been redirected, a page with a different URL is opened. Similarly, domain redirection or domain forwarding is when all pages in a URL domain are redirected to a different domain, as when wikipedia.com and wikipedia.net are automatically redirected to wikipedia.org.
> URL redirection is done for various reasons...

---

<div class="post-metadata">

**Author:** ![novicetoruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@novicetoruby](https://www.ruby-forum.com/u/novicetoruby)\
**Post date:** [August 22, 2009, 6:02pm UTC](https://www.ruby-forum.com/t/redirected-url/174181/3 "2009-08-22T18:02:05Z")

</div>

Thanks for you reply. I know the difference. I resolved this issue by  
sending ‘User-Agent’ value in header.

Thanks,  
Anil.

7stud – wrote:

> Anil K. wrote:
> 
> > Hi,  
> > I was trying to parse a web page where multiple hyper links exist.  
> > Each hyper link redirecting to a different server. I just want store  
> > first server it is redirecting the request too.
> > 
> > I tried using ‘net/http’ to capture ‘Location’ from response. But not  
> > working. Showing ‘Location’ value as blank.
> 
> Do you know the difference between:
> 
> 1. parsing a web page and retrieving the first link’s href
> 
> and
> 
> 1. examining a response’s Location header
> 
> [URL redirection - Wikipedia](http://en.wikipedia.org/wiki/URL_redirection)
