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 tob_iblock_element_prop_s*andb_iblock_element - Email templates in
mainmodule — often contain hardcoded URLs







