in reply to Referer check within domain problem
Is it possible that $ENV{'HTTP_REFERER'} contains an ip address?
If so, add in the appropriate checks.