Welcome to WebmasterWorld Guest from 54.205.209.95

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP header, long URLs and Internet Explorer

   
9:18 am on Aug 4, 2010 (gmt 0)

5+ Year Member



There was an old topic (already closed) about the same issue, actually without any reasonable answer what is happening.
We faced the same problem so I thought I post a short description and solution of the problem here to make others' live easier. ;-)


Old post:
[webmasterworld.com...]

The problem:
PHP header command (using 'refresh', 'location' or any other URL-related command) does not work in IE6 (and some versions of IE7) if the URL is longer then 255 chars.

Solutions:

1.) Use HTML META refresh tag:
<meta http-equiv="refresh" content="5;url=LONGURL">
(used by Travelgrove for example).
2.) Use JS redirects:
<script type='text/javascript'>
if (version>=4 || window.location.replace)
setTimeout("window.location.replace('LONGURL')",1000);
else
window.location.href = "LONGURL";
</script>
CAREFUL! LONGURL should contain ' and " encoded: %22 and %27.
(Used by travelgrove.com [travelgrove.com] and bookingwiz).

3.) Do NOT use too long URLs at all. :P
11:34 am on Aug 4, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



PHP header command (using 'refresh', 'location' or any other URL-related command) does not work in IE6 (and some versions of IE7) if the URL is longer then 255 chars.


I do not see this problem with the PHP header location at least and IE6. Make sure you don't emit garbage characters in the url.

Example:
<?php
$string = 'http://www.example.com/?';
for($i=0, $j=100; $i<$j; $i++) {
$string .= 'test' . $i . '=' . 'test' . $i . '&';
}
header('Location: ' . $string);
exit();
?>

You should fix the application code imo.
3:14 pm on Aug 6, 2010 (gmt 0)

5+ Year Member



You are right, sorry - only the Refresh header fails:

header("Refresh: 5; url=http://www.travelgrove.com/?a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3&a[]=1&b[]=2&c[]=3");


You can check it here:
[travelgrove.com...]
It does not work for me in IE6/7.

Thanks for your contribution.