/**
  * Redirects to a specified page or URL.
  *
  * @param mixed $redirect Page id or URL to redirect to
  * @param boolean $correctRedirectUrl replace & with & in URL
  * @return void
  */
 public function doRedirect($redirect, $correctRedirectUrl, $additionalParams = [], $headerStatusCode = '')
 {
     // these parameters have to be added to the redirect url
     $addParams = [];
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('L')) {
         $addParams['L'] = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('L');
     }
     if (is_array($additionalParams)) {
         foreach ($additionalParams as $param => $value) {
             if (FALSE === strpos($param, '.')) {
                 if (is_array($additionalParams[$param . '.'])) {
                     $value = $this->getSingle($additionalParams, $param);
                 }
                 $addParams[$param] = $value;
             }
         }
     }
     $url = $this->globals->getCObj()->getTypoLink_URL($redirect, $addParams);
     //correct the URL by replacing &
     if ($correctRedirectUrl) {
         $url = str_replace('&', '&', $url);
     }
     if ($url) {
         if (!$this->globals->isAjaxMode()) {
             $status = '303 See Other';
             if ($headerStatusCode) {
                 $status = $headerStatusCode;
             }
             header('Status: ' . $status);
             header('Location: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($url));
         } else {
             print '{' . json_encode('redirect') . ':' . json_encode(\TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($url)) . '}';
             exit;
         }
     }
 }