功能不适用于IIS

时间:2013-03-27 17:34:32

标签: php mysql iis azure

我在用户登录后使用此功能重定向到投资组合...

function redirect($destination) 
{

    //handle url
    if (preg_match("/^https?:\/\//", $destination))
    {
        header("Location: " . $destination);
    }

    // handle absolute path
    else if (preg_match("/^\//", $destination))
    {
        $protocol = (isset($_SERVER["HTTPS"])) ? "https" : "http";
        $host = $_SERVER["HTTP_HOST"];
        header("Location: $protocol://$host$destination");
    }

    // handle relative path
    else
    {
        // adapted from http://www.php.net/header
        $protocol = (isset($_SERVER["HTTPS"])) ? "https" : "http";
        $host = $_SERVER["HTTP_HOST"];
        $path = rtrim(dirname($_SERVER["PHP_SELF"]), "/\\");
        header("Location: $protocol://$host$path/$destination");
    }

    // exit immediately since we're redirecting anyway
    exit;
}

使用它会在chrome中产生SSL连接错误:     错误107(net :: ERR_SSL_PROTOCOL_ERROR):SSL协议错误。 在Firefox中     连接到localhost期间发生错误:63077。

SSL received a record that exceeded the maximum permissible length.

(错误代码:ssl_error_rx_record_too_long

请不要告诉我这个问题...... 告诉我解决方案或替代方案 我有一个Windows azure帐户... 它甚至不在那里工作...... 亲切的问候 维沙尔

PS:我知道这会花费很多时间...... 我真的需要这个用于我的想象杯项目..

1 个答案:

答案 0 :(得分:0)

似乎您在获取正确的协议时遇到问题。我不确定这是否适用于IIS,但我通常在Linux上使用以下内容 - 无法想象为什么它不起作用:

function getProtocol()
{
        return $_SERVER['SERVER_PORT']=='443'?'https://':'http://';
}

这应该可以消除代码中的大部分复杂性吗?

相关问题