Answer the question
In order to leave comments, you need to log in
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
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;?>
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
<?if(CSite::InDir('/catalog/index.php')):?>
// здесь будет вызов простого компонента из файла sections.php компонента catalog
<?else:?>
// здесь твой компонент catalog
<?endif;?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question