Prestashop 重定向不准确 url
Prestashop redirect not exact url
我需要将不准确的 URL 重定向到 404 页面
我的意思是:
现有URL
http://something.com/2-sport-shoes
不准确URL
http://something.com/2-dsajdhasudhas 被重定向到 http://something.com/2-sport-shoes 因为链接共享相同的 ID (2
)
Prestashop 如何将不准确的 url 重定向到 404?
解决方案
修改CategoryController
public function canonicalRedirection($canonical_url = '')
{
if (Tools::getValue('live_edit')) {
return;
}
if (!Tools::getValue('noredirect') && Validate::isLoadedObject($this->category)) {
$exact_url= parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$link = $this->category->id . "-" . $this->category->link_rewrite;
if($exact_url != $link) {
Tools::redirect('index.php?controller=404');
}
}
}
我需要将不准确的 URL 重定向到 404 页面
我的意思是:
现有URL
http://something.com/2-sport-shoes
不准确URL
http://something.com/2-dsajdhasudhas 被重定向到 http://something.com/2-sport-shoes 因为链接共享相同的 ID (2
)
Prestashop 如何将不准确的 url 重定向到 404?
解决方案
修改CategoryController
public function canonicalRedirection($canonical_url = '')
{
if (Tools::getValue('live_edit')) {
return;
}
if (!Tools::getValue('noredirect') && Validate::isLoadedObject($this->category)) {
$exact_url= parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$link = $this->category->id . "-" . $this->category->link_rewrite;
if($exact_url != $link) {
Tools::redirect('index.php?controller=404');
}
}
}