mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 19:21:40 +09:00
Implement redirect to default domain if unregistered domain is requested
This commit is contained in:
parent
79f29b3372
commit
2e3e969767
3 changed files with 28 additions and 1 deletions
|
|
@ -273,7 +273,7 @@ class Context
|
|||
}
|
||||
|
||||
// Redirect to SSL if the current domain always uses SSL.
|
||||
if ($site_module_info->security === 'always' && !RX_SSL && PHP_SAPI !== 'cli')
|
||||
if ($site_module_info->security === 'always' && !RX_SSL && PHP_SAPI !== 'cli' && !$site_module_info->is_default_replaced)
|
||||
{
|
||||
$ssl_url = self::getDefaultUrl($site_module_info) . RX_REQUEST_URL;
|
||||
self::setCacheControl(0);
|
||||
|
|
|
|||
|
|
@ -127,6 +127,31 @@ class ModuleHandler extends Handler
|
|||
$oModuleModel = getModel('module');
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
// Check unregistered domain action.
|
||||
if (!$site_module_info || !isset($site_module_info->domain_srl) || $site_module_info->is_default_replaced)
|
||||
{
|
||||
$site_module_info = getModel('module')->getDefaultDomainInfo();
|
||||
$domain_action = config('url.unregistered_domain_action') ?: 'redirect_301';
|
||||
switch ($domain_action)
|
||||
{
|
||||
case 'redirect_301':
|
||||
header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 301);
|
||||
return false;
|
||||
|
||||
case 'redirect_302':
|
||||
header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 302);
|
||||
return false;
|
||||
|
||||
case 'block':
|
||||
$this->error = 'The site does not exist';
|
||||
$this->httpStatusCode = 404;
|
||||
return true;
|
||||
|
||||
case 'display':
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
// if success_return_url and error_return_url is incorrect
|
||||
$urls = array(Context::get('success_return_url'), Context::get('error_return_url'));
|
||||
foreach($urls as $url)
|
||||
|
|
@ -155,6 +180,7 @@ class ModuleHandler extends Handler
|
|||
}
|
||||
}
|
||||
|
||||
// Convert document alias (entry) to document_srl
|
||||
if(!$this->document_srl && $this->mid && $this->entry)
|
||||
{
|
||||
$oDocumentModel = getModel('document');
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ class moduleModel extends module
|
|||
{
|
||||
$domain_info = $this->migrateDomains();
|
||||
}
|
||||
$domain_info->is_default_replaced = true;
|
||||
}
|
||||
|
||||
// Fill in module extra vars and return.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue