You can work out the URL with a combination of the following server variables:
HTTP_HOST
SECURE
SCRIPT_NAME
PATH_INFO
QUERY_STRING
And possibly a few more. See the CGI specification for more info.
This still won't give you the full URL however, as a "fragment" part (.e.g #someanchor) is not sent to the server.
The server can't know what fragment the client used.
Mark