diff --git a/contao/library/Contao/System.php b/contao/library/Contao/System.php
index 5a0bacc385..050281d2ff 100644
--- a/contao/library/Contao/System.php
+++ b/contao/library/Contao/System.php
@@ -213,16 +213,13 @@ public static function reload()
// Ajax request
if (\Environment::get('isAjaxRequest'))
{
- echo $strLocation;
- exit;
+ echo '';
}
-
- if (headers_sent())
+ elseif (!headers_sent())
{
- exit;
+ header('Location: ' . $strLocation);
}
- header('Location: ' . $strLocation);
exit;
}
@@ -240,39 +237,42 @@ public static function redirect($strLocation, $intStatus=303)
// Ajax request
if (\Environment::get('isAjaxRequest'))
{
- echo $strLocation;
- exit;
- }
-
- if (headers_sent())
- {
- exit;
+ if (preg_match('@^https?://@i', $strLocation))
+ {
+ echo '';
+ }
+ else
+ {
+ echo '';
+ }
}
-
- // Header
- switch ($intStatus)
+ elseif (!headers_sent())
{
- case 301:
- header('HTTP/1.1 301 Moved Permanently');
- break;
+ // Header
+ switch ($intStatus)
+ {
+ case 301:
+ header('HTTP/1.1 301 Moved Permanently');
+ break;
- case 302:
- header('HTTP/1.1 302 Found');
- break;
+ case 302:
+ header('HTTP/1.1 302 Found');
+ break;
- case 303:
- header('HTTP/1.1 303 See Other');
- break;
- }
+ case 303:
+ header('HTTP/1.1 303 See Other');
+ break;
+ }
- // Check the target address
- if (preg_match('@^https?://@i', $strLocation))
- {
- header('Location: ' . $strLocation);
- }
- else
- {
- header('Location: ' . \Environment::get('base') . $strLocation);
+ // Check the target address
+ if (preg_match('@^https?://@i', $strLocation))
+ {
+ header('Location: ' . $strLocation);
+ }
+ else
+ {
+ header('Location: ' . \Environment::get('base') . $strLocation);
+ }
}
exit;