mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Add Context::redirect() method
This commit is contained in:
parent
8a012a5847
commit
4c47793828
1 changed files with 16 additions and 3 deletions
|
|
@ -252,9 +252,8 @@ class Context
|
|||
// Redirect to SSL if the current domain requires SSL.
|
||||
if (!RX_SSL && PHP_SAPI !== 'cli' && $site_module_info->security !== 'none' && !$site_module_info->is_default_replaced)
|
||||
{
|
||||
$ssl_url = self::getDefaultUrl($site_module_info, true) . RX_REQUEST_URL;
|
||||
self::setCacheControl(0);
|
||||
header('Location: ' . $ssl_url, true, 301);
|
||||
$url = self::getDefaultUrl($site_module_info, true) . RX_REQUEST_URL;
|
||||
self::redirect($url, 301);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
@ -502,6 +501,20 @@ class Context
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $status_code
|
||||
* @param int $ttl
|
||||
* @return void
|
||||
*/
|
||||
public static function redirect(string $url, int $status_code = 302, int $ttl = 0): void
|
||||
{
|
||||
header("Location: $url", true, $status_code);
|
||||
self::setCacheControl($ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the database information
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue