From 176af9086428b04357ecef7ff2ebe687b63e1f09 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 3 Jan 2014 13:50:32 -0600 Subject: [PATCH] http: Legacy versions of IIS redirect incorrectly (And newer versions don't seem to like the legacy code). This patch uses a `Refresh` header for IIS versions prior to 7.0 (included with Windows Vista / Server 2008). Starting with IIS 7.0, the Location header should be properly handled by IIS. --- include/class.http.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/class.http.php b/include/class.http.php index 8d4e7be20..5502e9849 100644 --- a/include/class.http.php +++ b/include/class.http.php @@ -40,10 +40,15 @@ class Http { print $content; exit; } - - function redirect($url,$delay=0,$msg='') { - if(strstr($_SERVER['SERVER_SOFTWARE'], 'IIS')){ + function redirect($url,$delay=0,$msg='') { + + $iis = strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') !== false; + @list($name, $version) = explode('/', $_SERVER['SERVER_SOFTWARE']); + // Legacy code for older versions of IIS that would not emit the + // correct HTTP status and headers when using the `Location` + // header alone + if ($iis && version_compare($version, '7.0', '<')) { header("Refresh: $delay; URL=$url"); }else{ header("Location: $url"); -- GitLab