Очень дико
Надо как в seo_pro.php
private function validate()
{
$cnt_cnt = $this->config->get('asc_cnt_cnt');
if (isset($this->request->get['route']) && $this->request->get['route'] == 'error/not_found') {
return;
}
if (empty($this->request->get['route'])) {
$this->request->get['route'] = 'common/home';
}
if (isset($this->request->server['HTTP_X_REQUESTED_WITH']) && strtolower($this->request->server['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
return;
}
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
$config_url = substr($this->config->get('config_ssl'), 0, $this->strpos_offset('/', $this->config->get('config_ssl'), 3) + 1);
$url = str_replace('&', '&', ltrim($this->request->server['REQUEST_URI'], '/'));
$seo = str_replace('&', '&', str_replace($config_url, '', $this->url->link($this->request->get['route'], $this->getQueryString(array(
'route',
'_route_',
'site_language'
)), 'SSL')));
} else {
$config_url = substr($this->config->get('config_url'), 0, $this->strpos_offset('/', $this->config->get('config_url'), 3) + 1);
$url = str_replace('&', '&', ltrim($this->request->server['REQUEST_URI'], '/'));
$seo = str_replace('&', '&', str_replace($config_url, '', $this->url->link($this->request->get['route'], $this->getQueryString(array(
'route',
'_route_',
'site_language'
)), 'NONSSL')));
}
if (rawurldecode($url) != rawurldecode($seo)) {
header($this->request->server['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
$this->response->redirect($config_url . $seo);
}
}
private function strpos_offset($needle, $haystack, $occurrence)
{
$arr = explode($needle, $haystack);
switch ($occurrence) {
case $occurrence == 0:
return false;
case $occurrence > max(array_keys($arr)):
return false;
default:
return strlen(implode($needle, array_slice($arr, 0, $occurrence)));
}
}
private function getQueryString($exclude = array())
{
if (!is_array($exclude)) {
$exclude = array();
}
return urldecode(http_build_query(array_diff_key($this->request->get, array_flip($exclude))));
}