Problem solved. The source of the trouble is that early versions of Safari insist on a blank line after the Location header in a redirect. Thanks to Trevor Blackwell for proposing this.
In the latest release, everything seems to work, at least in Safari 1.3.
The simplest reproduction of the problem is:
https://hackertimes.com/safaritest
which redirects to apple.com in other browsers but generates an error in early versions of Safari.
I'd be very grateful if any Safari expert out there could tell me what's going wrong.