I
I
IliaMal2020-05-08 13:44:53
1C-Bitrix
IliaMal, 2020-05-08 13:44:53

How to remove /catalog/ on section pages in CNC?

Hello!

Rewriting the site from scratch.
For SEO, it is important that the urls remain the same as before.

By default, in Bitrix, a link to a section looks like this {domain}/catalog/{section}/ , but I need to bring it to the form {domain}/{section}/ .

There are a lot of crutches on the old site, copy-paste is not an option. Tell me how to implement it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
PetrPo, 2020-05-09
@IliaMal

1. Remove "url of the infoblock page" /catalog/
from the infoblock settings 2. Open the component settings through the public (through the public so that the urlrewrite will rewrite itself when saving) in "page address management" -> "CNC catalog (relative to the site root)" ( SEF_FOLDER) also remove the catalog, leave it simple /
If you do this, the urls will become as you need, but the section root will stop working correctly.
To fix in index.php you write a condition

<?if(CSite::InDir('/catalog/index.php')):?>
// здесь будет вызов простого компонента из файла sections.php компонента catalog
<?else:?>
// здесь твой компонент catalog
<?endif;?>

You can first do the first part, check that the sections and elements work correctly.
I’ll clarify why the catalog root will not work correctly, since the section address /section code/ and the component are located in the /catalog/ section, then Bitrix will think that catalog is also a section in the infoblock with the symbolic code catalog, and accordingly, since there is no such section, it will be 404, so you have to do a little crutch.

I
IvanMogilev, 2020-05-08
@IvanMogilev

In the infoblock settings, remove catalog in the fields URL of the page of the information block, URL of the section page, URL of the detailed view page, the same thing in the component call, resave the processing rules, if it works out like this

P
Pavel Sidorov, 2021-06-03
@pavel__sidorov

<?if(CSite::InDir('/catalog/index.php')):?>
// здесь будет вызов простого компонента из файла sections.php компонента catalog
<?else:?>
// здесь твой компонент catalog
<?endif;?>

Friend, post what you got here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question