NYCPHP Meetup

NYPHP.org

[nycphp-talk] Help -- header redirection problem

Cliff Hirsch cliff at pinestream.com
Wed Sep 27 10:39:54 EDT 2006


Carlos:

Yep -- you the man. I finally figured this out, but you're the first
person that saw it too. 

Was hard to see when it was deeply buried in my application. Lesson
learned -- Cliff, don't call an http/https redirect function twice with
varying conditions you really know what your doing! Translation -- be
careful with that BASIC-style goto code.

Thanks,
Cliff

P.S. But all is not lost. I picked up a new word. I'll try it tonight --
"Hun, you borked the lasagna again."

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of Carlos A Hoyos
Sent: Wednesday, September 27, 2006 9:00 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Help -- header redirection problem

Without running it, I'd say this script makes an infinite loop. When the
redirect is sent, isn't the else being executed again?

> Bork? Is that in the dictionary?!
>
> I just completely isolated the script down to this:
>
> <?
> $sslmode = 'https';
> $domain = $_SERVER['HTTP_HOST'];
> $uri = $_SERVER['REQUEST_URI'];
> $path = $domain.$uri;
> $sslon = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ?
true
> : false;
> if ($sslmode == 'http' && $sslon) {
>    header("Location: http://$path");
>    exit;
>    }
> elseif ($sslmode == 'https' && !$sslon) {
>    header("Location: https://$path");
>    exit;
> }
> else {
>    header("Location: https://$path");
>    exit;
> }
> ?>
>
> This fails, but comment out the last header and exit in the else and
it
> work. Perhaps I have been borked. Where do I check for
> borking/mod_rewrite? Next step is to download PHP 5.1.6 to see if that
> solves the problem.
>
> Cliff

Carlos





More information about the talk mailing list