You need to change
$goto = $rec->{URL};
to
$goto = $rec->{DownloadURL};
or whatever you have called the field with your new URL in it.
$goto = $rec->{URL};
to
$goto = $rec->{DownloadURL};
or whatever you have called the field with your new URL in it.