Redirect the page to find the URL using Ruby


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
3 views
Have the address: site.com/?foo=bar
When you navigate to it the server gives an HTTP Location header with the redirection to the second address, for example site.com/products/foo_id/bar_id

I only know the source (http://site.com/?foo=bar) how to use ruby to know the address where it redirects?
by | 3 views

1 Answer

0 like 0 dislike
require 'open-uri' puts open('http://site.com/?foo=bar').base_uri.to_s
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
27,926 users