Forum Moderators: coopster

Message Too Old, No Replies

PHP header("location:http://verylongdynamicurl"); & Internet Explorer

IE 6 is not redirecting the page, help please.

         

Christopher C

6:40 am on Apr 20, 2004 (gmt 0)

10+ Year Member



Hello,

Does anyone know how to fix IE's (6.0) issue with php redirecting long urls? I know the url is formatted correctly because everything is working fine in mozilla and also if I manually cut and paste the url into internet explorer. For some reason however, the header(location) function will not redirect to the appropriate location in IE (it redirects to "/").

What I want to do is simple:

$go_to_url = "http://verylongdynamicurl";
header("location: $go_to_url");

After wasting a month of affiliate income on this site not realizing IE wasn't redirecting, suggestions on how to get this fixed asap would be greatly appreciated.

Thanks,
Chris

*I will not get used to only using mozilla*
*I will not get used to only using mozilla*
*I will not get used to only using mozilla*
*I will not get used to only using mozilla*

jamesa

11:26 am on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try an upper case "L" in the word "Location":

header("Location: $go_to_url");

Supposedly IE is picky about that. If that doesn't work there's some interesting user comments on this page [us4.php.net] (php.net).

Christopher C

5:13 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



Thanks for the suggestions, unfortunately I'm still stuck at the same spot.

I'm at a complete loss here. I've spent 3 hours trying to figure out what's going on. Much longer and I'm going to be prematurely bald from all the hair I'm pulling out.

No matter what I do, internet explorer will simply not accept and pass on the url. What I find the most infuriating is that if I manually set the variable equal to the url (rather than dynamically generating it, the redirect works fine.

This works
$go_to = "http://somelongurl";
header("Location: $go_to");

This does not work
$go_to = "http://start";
$go_to .= "op%3Dadd";
$go_to .= "%26type%3D".$type;
...
/* After a number of lines, $go_to is now the same as it was in the above example*/

header("Location: $go_to");

What happens in the bottom case, instead of forwarding to $go_to, the page forwards back to my site's homepage, i.e. ("/").

Does anyone know what's going on? I'm utterly and completely at a loss now.

Thanks,
Chris

ergophobe

5:21 pm on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




What I find the most infuriating is that if I manually set the variable equal to the url (rather than dynamically generating it, the redirect works fine.

Then you are doing something in your code that, when generating the url, changes it in some way and that change is tolerated by some browsers, but not by IE.

Have you tried outputting the generated url and just stopping and then cutting and pasting into IE to see what happens?

jatar_k

5:25 pm on Apr 20, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try generating them with the = and & instead of %3D and %26

Christopher C

5:41 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



>>Have you tried outputting the generated url and just stopping and then cutting and pasting into IE to see what happens? <<
Yes, this works fine.

>>Then you are doing something in your code that, when generating the url, changes it in some way and that change is tolerated by some browsers, but not by IE.<<
I would have thought so too, I've painstakingly compared every single character to the one that prints out, and it's exactly the same. I've checked three times.

>>try generating them with the = and & instead of %3D and %26<<
Trying this right now.

Christopher C

5:47 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



>>try generating them with the = and & instead of %3D and %26<<
Didn't work :( I've also tried converting the "." and "/" as well to no avail.

Something is happening with the way that the url is encoded in PHP when dynamically generated versus explicitly entered.

SEOtop10

5:47 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



Hi Christopher

Where is your '?'

Did you miss out on the '?'. Of course you know that the dynamic URLs look like [domain.com?id1=abc&id2=xyz...]

Arun

Christopher C

6:00 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



Hi Arun,

It's there, I just simplified. The url looks something like.

http:**foo1.com/foo.cgi?aid=123&redirect=http%3A%2F%2Fwww.fooaffiliate.com%2FMG%2Fcart.asp%3F...

(The ** are actually // of course)

Silicon

6:05 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



<?php

$url=substr($_SERVER['QUERY_STRING'],4);
header('Location: ['.$url);...]

?>

The length 4 is just the length of the string url= and must be changed if you use a different name.

In fact, I suppose that those fanatic about conserving bytes could just use this--

<?php

header('Location: ['.$_SERVER['QUERY_STRING']);...]

?>

[edited by: jatar_k at 7:04 pm (utc) on April 20, 2004]
[edit reason] removed url [/edit]

jamesa

6:54 pm on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>What I find the most infuriating is that if I manually set the variable equal to the url (rather than dynamically generating it, the redirect works fine.

Ahh. Try this (single quotes instead of double quotes):

$go_to_url = 'http://verylongdynamicurl';

Timotheos

8:36 pm on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This tool
[searchengineworld.com...]
will show you the server header. Maybe it will yield some clues.

JollyK

9:38 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



Silly question, probably, but what happens if, instead of using header(), you instead do something like:

echo "Location: $go_to_url\n\n";

Maybe "header()" adds other headers that IE doesn't like? (I'm not really a php person, so I don't know what the header() function actually does...just a thought.)

Christopher C

10:26 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



Thanks so much for the help everyone, it's very appreciated.

I've got it fixed and working now and to be honest I really haven't a clue what was wrong. In the end I just ended up scrapping the whole script and restarting it from scratch. Lost a day but it's working again so at this point I'm content. :)

Thanks again,
Chris