Setting up semantic URLs (CHPU) in 1C-Bitrix

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

SEF URL (Semantic URL) Setup for Bitrix CMS

SEF URL (Search Engine Friendly URL) — addresses like /catalog/laptops/apple-macbook-pro-14/ instead of /catalog/?ID=1234&ELEMENT_ID=5678. Bitrix supports SEF URLs for infoblocks via URL_TEMPLATES mechanism in infoblock settings and component templates. Without proper setup, components generate ugly URLs with parameters, poorly indexed.

Infoblock URL Template Setup

In infoblock settings (Content → Infoblocks → [infoblock] → Edit) in "SEF settings" tab, four templates are configured:

Template Example
Element page /catalog/#SECTION_CODE_PATH#/#CODE#/
Section page /catalog/#SECTION_CODE_PATH#/
Element list /catalog/
Section page (type 2) (optional)

#CODE# — element symbolic code. #SECTION_CODE_PATH# — path of symbolic codes of all parent sections via /. #ID# — numeric ID (worse for SEO).

Symbolic codes (CODE) must be filled for all sections and elements. During import from 1C or Excel they're often missing — autogeneration of code from name (transliteration) or force generation via script needed.

Component Setup

Components bitrix:catalog, bitrix:news, bitrix:news.detail and other infoblock components accept SEF_MODE = Y parameter and SEF_URL_TEMPLATES parameters:

$APPLICATION->IncludeComponent('bitrix:catalog', '', [
    'IBLOCK_ID'        => 5,
    'SEF_MODE'         => 'Y',
    'SEF_FOLDER'       => '/catalog/',
    'SEF_URL_TEMPLATES' => [
        'section'         => '#SECTION_CODE_PATH#/',
        'element'         => '#SECTION_CODE_PATH#/#CODE#/',
        'compare'         => 'compare/',
    ],
    'VARIABLE_ALIASES' => [
        'PAGEN_1'  => 'page',
    ],
]);

SEF_FOLDER — component base path. All URLs generated by component built relative to it. VARIABLE_ALIASES makes pagination more readable: /catalog/laptops/page/2/ instead of /catalog/laptops/?PAGEN_1=2.

.htaccess / nginx Setup

SEF URLs work through URL rewriting to PHP handler. In site root, .htaccess file should contain RewriteRule that redirects all requests to non-existent files to index.php:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [L]

Bitrix adds this automatically during installation, but if .htaccess was overwritten — rule must be restored.

For nginx, equivalent configuration:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Autogeneration of Symbolic Codes

When adding new element via admin form, symbolic code can be autogenerated from name via transliteration. In infoblock settings SEF settings → Automatically generate symbolic code. Transliteration rules configured in Settings → Product Settings → Transliteration.

For mass filling empty codes in existing elements:

$res = \CIBlockElement::GetList([], ['IBLOCK_ID' => 5, 'CODE' => false]);
$el = new \CIBlockElement();
while ($item = $res->Fetch()) {
    $code = \CUtil::translit($item['NAME'], 'ru', [
        'max_len'        => 100,
        'change_case'    => 'L',
        'replace_space'  => '-',
        'replace_other'  => '-',
        'delete_repeat'  => true,
    ]);
    $el->Update($item['ID'], ['CODE' => $code]);
}

Implementation Timeline

SEF URL setup for one infoblock (URL templates, component parameters, .htaccess) — 1–2 hours. If additionally need mass code generation and 301 redirects from old URLs — 3–5 hours.