1 redirect.module redirect_goto(Redirect $redirect)

Redirect callback; perform an URL redirect.

Parameters

Redirect $redirect: The Redirect that should be executed.

Return value

NULL: This function will end the execution of the current page.

File

core/modules/redirect/redirect.module, line 949

Code

function redirect_goto(Redirect $redirect) {
  $redirect->redirect_options['absolute'] = TRUE;
  $url = url($redirect->redirect, $redirect->redirect_options);
  backdrop_add_http_header('Location', $url);
  backdrop_add_http_header('Status', redirect_status_code_options($redirect->status_code));

  if (!empty($redirect->rid)) {
    // Add a custom header for the redirect ID. This allows redirect usage to
    // be tracked even when the page is served from a cache.
    backdrop_add_http_header('X-Redirect-ID', $redirect->rid);
  }

  // Invoke hook_exit() and set the page cache (if enabled). The redirect will
  // be cached for the same lifetime as the normal expiration setting from
  // the performance page.
  backdrop_page_footer();
  exit();
}