function redirect_goto in Redirect 7.2
Same name and namespace in other branches
- 7 redirect.module \redirect_goto()
Redirect callback; perform an URL redirect.
1 string reference to 'redirect_goto'
- redirect_redirect in ./
redirect.module - Perform an URL redirect.
File
- ./
redirect.module, line 1183
Code
function redirect_goto($redirect) {
$redirect->redirect_options['absolute'] = TRUE;
// Check if this points on a file on the server.
if (file_exists(DRUPAL_ROOT . '/' . $redirect->redirect)) {
// We don't use url() directly for files to avoid a language prefix being added.
$url = url(file_create_url($redirect->redirect), $redirect->redirect_options);
}
else {
$url = url($redirect->redirect, $redirect->redirect_options);
}
drupal_add_http_header('Location', $url);
drupal_add_http_header('Status', redirect_status_code_options($redirect->status_code));
if (!empty($redirect->rid)) {
// Add a custom header for the redirect ID so when the redirect is served
// from the page cache, we can track it.
drupal_add_http_header('X-Redirect-ID', $redirect->rid);
}
if (!variable_get('redirect_page_cache', 0) || !variable_get('cache', 0) || !drupal_page_is_cacheable() || empty($redirect->cache)) {
drupal_exit($url);
}
// @see drupal_exit()
if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
module_invoke_all('exit', $url);
}
drupal_session_commit();
if (variable_get('cache', 0)) {
// We must output something to allow the request to be cached.
echo ' ';
if ($cache = drupal_page_set_cache()) {
// When caching this redirect for the first time we still need to ensure
// that the correct cache headers are sent.
// @see drupal_page_footer()
drupal_serve_page_from_cache($cache);
}
}
}
exit;
}