How do I get the URL that my script is being acessed from by the user?

Example: A script can be accessed by going to http://hosta.domain/script/, or http://hosta.domain/script/index.cgi, or http://hostb.domain/mirror/script/index.cgi. How can I tell which URL the user typed into their browser from within the script itself?