Setting up domain linking to 1C-Bitrix sites

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
    1189
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    813
  • 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
    657
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Setting up Domain Binding to Sites in 1C-Bitrix

Multi-site capability in Bitrix is one of the key features, allowing multiple sites to be served from one kernel. Binding a domain to a site is the first step, and there are nuances here that, if incorrectly configured, result in all domains showing the same site or redirecting incorrectly.

How Bitrix determines the current site

With each request, the Bitrix kernel reads table b_lang and searches for a record where SERVER_NAME field matches the HTTP header Host of the incoming request. The found LID (two-letter site code) is used for all subsequent operations: template selection, infoblocks, language, etc.

SELECT LID, DIR, NAME, SERVER_NAME FROM b_lang WHERE ACTIVE = 'Y';

If SERVER_NAME doesn't match any record — Bitrix uses the first site by default or returns an error depending on configuration. This is why "all domains show the same site".

Adding domain to site through admin

In /bitrix/admin/site_edit.php?LID=<site_code>, fill in the "Domain name of server" field (SERVER_NAME). Enter domain without http:// and without slash: example.com.

If the site should work on both www.example.com and example.com — choose one as primary, configure the second as a redirect at the web server level (nginx/Apache), not through Bitrix. Don't try to enter both in SERVER_NAME — the field doesn't support multiple values.

The DIR field is the path to the site directory relative to root. For the main site — /. For a second site on the same server — /second/ or the same / if sites are separated only by domain.

Web server configuration

Bitrix handles routing within its kernel, but the web server must accept requests to the required domains and pass them to the Bitrix root.

Nginx: separate server {} block for each domain or common block with server_name example.com example2.com. Document root is the same — Bitrix installation root.

server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/bitrix;
    # ... standard Bitrix configuration
}

HTTPS: separate SSL certificate needed for each domain or wildcard/multi-domain certificate. Let's Encrypt issues certificates for multiple domains through certbot --domains example.com,example2.com.

Domain masking and URL aliases

Scenario: primary domain main-shop.ru and partner domain partner-shop.ru should show the same site but with different branding. In Bitrix this is implemented by checking $_SERVER['HTTP_HOST'] in init.php or template with conditional inclusion of different template — this is not standard multi-site, but a custom solution.

Standard multi-site assumes different templates, different languages and different content for each site. If you need one content on different domains — use canonical URL in <head> to indicate primary domain and avoid SEO duplication.

Moving site to new domain

When changing domain, update SERVER_NAME in b_lang, then check:

  • Settings $_SERVER['HTTP_HOST'] in /bitrix/.settings.php (if explicitly specified)
  • Site URL in module settings: COption::GetOptionString("main", "server_name") — in some versions stored there
  • Links in infoblock content — absolute links like http://old-domain.ru/... need replacing through SQL queries to b_iblock_element_prop_s* and b_iblock_element
  • Email templates in main module — often contain hardcoded URLs