symŽ has asked for the wisdom of the Perl Monks concerning the following question:

Can someone tell my why location headers are acting so strange on IE?
I am just doing a simple print "location: http://$url\n\n";
It works great with netscape, but IE hates it and just returns the original document.

Weird.

Replies are listed 'Best First'.
Re: location headers and IE
by turnstep (Parson) on Mar 28, 2000 at 22:35 UTC

    I did some testing, and IE does not seem to care about the capitilization of the location. Basically, one of three things happen:

    1. The page opens correctly, if everything is alright
    2. An error page is generated, if the script has an error, or you forget the second newline, etc.
    3. It complains about not being able to open the new page, expecially if you are using relative URLs (I suspect you are not)
    I have not been able to duplicate your experience. Try rewriting the script like this to see exactly where IE is trying to go:
    print "Content-type: text/html\n\n"; print "<H1>Location: http://$url\n\n</H1>\n;

    It's probably just something wrong with the $url variable.

Re: location headers and IE
by btrott (Parson) on Mar 28, 2000 at 04:46 UTC
    Did you try using a capital "L" in Location?
    print "Location: $url\n\n";
    Alternatively, you might investigate using CGI.pm's redirect method:
    use CGI; my $query = new CGI; print $query->redirect($url);
    According to the docs, the redirect method uses both the Location: and the URI: headers--perhaps this will help?

    Also, browsers don't generally like relative URLs in the Location: headers... try switching to absolute URLs if you're using relative.