A redirect happens in one of two ways.
One, the server sends a web page to the client with the HTTP-EQUIV="refresh" meta tag. The client parses through the HTML, notices the refresh tag, and acts accordingly.
Two, the server sends an HTTP status to the client along with information on the redirected URL. It is up to the client to act on this status message. The status is part of the header info sent from the server. For example, a code of 200 is ok, 400's are errors (404, file not found), 500's are server errors. I believe 300's are status messages, one of which is for content has moved.
The point is that, in both scenarios, the action of following the URL is up to the client. So, depending on how you structured your program to read a URL, you should know if you're being redirected or not.