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.







