Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server Redirect - Capture New URL

Status
Not open for further replies.

SaRiD

Programmer
Apr 19, 2003
45
0
0
Hi

I am entering a url in php to capture the html code on that page.

This is working fine.

However, on some sites there is a redirect in place which returns a different page. How do I capture the full URL of the page that I was redirected to?

E.g. I entered " but the server redirected me to " and returned the html on that page. How can I find out what the URL of the page I was redirected to.

Make sense?
 
It depends on how the browser does the redirect.

If the web server is informing browsers of the redirected page, the server will return an HTTP response code in the 300 range (typically 302, "Moved permanently"), then specify the new location in a "Location" HTTP header. (See ftp://ftp.isi.edu/in-notes/rfc2616.txt) For your script to be aware of this method of redirection, your script must be cable of being aware of HTTP status codes and headers.

If the redirection comes from the HTML content in the form of a <META> tag (such as '<meta http-equiv="refresh" content="2;url=http://www.foo.bar/">', then your script must be aware of <META> tags.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top