in reply to retrieving an URL

There's no reliable way to do it. Any answer that lists $ENV{HTTP_REFERER} or something derived from it needs a disclaimer that states:
  1. It can be trivially faked
  2. It can be absent
  3. It can be wrong
So, beware the clueless attempting to give you clues.

-- Randal L. Schwartz, Perl hacker