// Merge -> revision 7941
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7948 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
class CategoryControllerCore extends FrontController
|
||||
{
|
||||
public $php_self = 'category';
|
||||
protected $category;
|
||||
|
||||
public function setMedia()
|
||||
@@ -47,6 +48,27 @@ class CategoryControllerCore extends FrontController
|
||||
parent::displayHeader();
|
||||
$this->productSort();
|
||||
}
|
||||
|
||||
public function canonicalRedirection()
|
||||
{
|
||||
if (Configuration::get('PS_CANONICAL_REDIRECT'))
|
||||
{
|
||||
// Automatically redirect to the canonical URL if the current in is the right one
|
||||
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
|
||||
if (Validate::isLoadedObject($this->category))
|
||||
{
|
||||
$currentURL = $this->context->link->getCategoryLink($this->category);
|
||||
$currentURL = preg_replace('/[?&].*$/', '', $currentURL);
|
||||
if (!preg_match('/^'.Tools::pRegexp($currentURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
|
||||
{
|
||||
header('HTTP/1.0 301 Moved');
|
||||
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_ )
|
||||
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$currentURL.'">'.$currentURL.'</a>');
|
||||
Tools::redirectLink($currentURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
@@ -58,19 +80,7 @@ class CategoryControllerCore extends FrontController
|
||||
header('Status: 404 Not Found');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Automatically redirect to the canonical URL if the current in is the right one
|
||||
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
|
||||
$currentURL = $this->context->link->getCategoryLink($this->category);
|
||||
$currentURL = preg_replace('/[?&].*$/', '', $currentURL);
|
||||
if (!preg_match('/^'.Tools::pRegexp($currentURL, '/').'([&?].*)?$/i', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
|
||||
{
|
||||
header('HTTP/1.0 301 Moved');
|
||||
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_ )
|
||||
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$currentURL.'">'.$currentURL.'</a>');
|
||||
Tools::redirectLink($currentURL);
|
||||
}
|
||||
}
|
||||
$this->canonicalRedirection();
|
||||
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user