Re: HTTP redirects, Location: header, and IE5 problems

From: Date: Wed, 27 Sep 2000 06:24:05 +0000
Subject: Re: HTTP redirects, Location: header, and IE5 problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-17680@lists.php.net to get a copy of this message
The suggestion to check the annotated notes is a good one. The relevant ones (for me) are in the setcookie() "manpage." It turns out that IE has trouble when setting a cookie and a header redirect at the same time. Several workarounds are suggested, such as using a META-tag cookie or redirect, or various sequencing tricks with PHP. I tried out several of these latter and none seem to work: all generate just the same output HTTP transcript. The answer is to leave off the "http://blah" part of the URL and just use the path part. I think this is an IE bug. The HTTP spec explicitly says that the Location: header should have a fully qualified URL. Fortunately, the versions of Netscape I checked seem to accept the path, so if you want to set cookies and do redirects using more canonical means, this is the workaround for the problem with IE. If you want to use META tag redirects, or some other scheme, that will also work. Word to the wise: many of the comments in the setcookie() notes are incorrect. -Greg Billock Lawrence.Sheed@dfait-maeci.gc.ca wrote: > You might want to try experimenting with adding cr/lf's in there, some > versions of IE are picky about that (and don't follow the spec, sigh). > > Have a look on php.net in the annotated notes for more info. > > -----Original Message----- > From: Greg Billock [mailto:billgr@sunoptics.caltech.edu] > Sent: September 23, 2000 03:14 AM > To: php-general@lists.php.net > Subject: [PHP] HTTP redirects, Location: header, and IE5 problems > > I have been frustrated recently working with IE5.01+ and > HTTP redirects. In PHP, these are most easily done with > the header("Location: $url"); call, which magically updates > the HTTP return code and everything. :-) > > So the problem is that Internet Explorer v. 5 and above > are just returning Error - Page Not Found when given data > like this. What is going on? > > At present, it looks to me like the problem is that IE5.01 > and IE5.5 are set to default not to honor the HTTP/1.0 spec, > and take absolute URLs in the Location header. Instead, > they display an error. If they are given a *relative* URL, > then they are OK. > > Can anyone confirm this as a general observation, or even > more specifically? Can IE5 be set not to ignore the specification > for HTTP headers? I have observed this broken behavior with > IE5.5 on two other sites besides those of mine which try to > do redirects. One looks like it uses Python to issue redirects > and the other uses Perl, so I think this is an issue with Explorer. > > As a workaround, Netscape seems to accept relative > paths in the Location header, so that is the indicated > thing. (I guess if you want to do off-site redirects, you > have to find some other mechanism. Perhaps the > HTTP/1.1 Content-location header? I'm not sure...) > > -Greg Billock > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#17680) next »