R
R
run1822020-02-27 22:00:45
1C-Bitrix
run182, 2020-02-27 22:00:45

How to configure 404 for filter pages if the parameter passed to the filter does not exist?

Question about the functionality of the catalog and smart filter.

There is a page with a brand filter: /catalog/smartphones/filter/brand-is-apple/
This brand exists and the page has successfully filtered products.

But, if you add a value to the filter that does not contain products (there is no such brand), for example: /catalog/smartphones/filter/brand-is-apple123/
Then the page will still open, but without the filter.

It turns out to be a problem for SEO. How can I track this moment in a smart filter to set up a 404?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2020-02-27
@run182

To the filter template
For example, along this path:
bitrix/templates/Template/components/bitrix/catalog.smart.filter/Template/template.php

$URL = $APPLICATION->GetCurDir();
if ($URL != $arResult[SEF_SET_FILTER_URL]) {
//echo 'ERROR 404';CHTTP::SetStatus("404 Not Found"); 
//@define("ERROR_404","Y");
//если раскомментировать - выдаст 404, иначе ниже - делаем редирект
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".$arResult[SEF_SET_FILTER_URL]);
exit();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question