Setting up HTTPS redirects 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
    1177
  • 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

HTTPS Redirect Setup in 1C-Bitrix

Redirecting from HTTP to HTTPS is a task that inexperienced developers often implement in multiple places simultaneously: in .htaccess, in init.php, and in Bitrix settings. The result is redirect chains that slow down page loading and confuse search engine crawlers.

The Right Place for Redirects

The redirect should exist in exactly one place. The preferred location is at the web server level, before PHP is invoked.

Nginx:

server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}

server {
    listen 443 ssl;
    server_name www.example.com;
    return 301 https://example.com$request_uri;
}

Apache (.htaccess):

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If the site is behind Cloudflare or another reverse proxy — configure the redirect in the CDN control panel; an additional server-level redirect is not needed (otherwise a redirect loop will occur).

www to non-www Redirect (and Vice Versa)

Choose a canonical domain and configure the redirect. In Bitrix, also specify the canonical domain under Settings → Sites → [site] — this affects how absolute URLs are generated in components.

In SEO settings (Content → SEO → Settings), enable the <canonical> tag — Bitrix will automatically insert the correct domain.

HSTS — Enforcing HTTPS at the Browser Level

Once HTTPS is stable, add the HSTS header in nginx:

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

Start with a short max-age (3600), confirm everything works, then increase it to 31536000. HSTS with preload and registration in browser preload lists is the next level and requires a separate procedure.

Verifying the Redirect Chain

curl -I -L http://www.example.com/ 2>&1 | grep -E "HTTP/|Location:"

Acceptable chain: a maximum of one 301. Two or more — there is a problem.

Real-World Case

A corporate website had redirects configured in .htaccess (www to non-www + HTTP→HTTPS), in init.php (an additional $_SERVER['HTTPS'] check), and in nginx. The total chain was 3 redirects. PageSpeed Insights flagged this as a critical issue. Solution: removed redirects from .htaccess and init.php, kept only the nginx config. Time to first byte improved by 150–300 ms.

Delivery Time

HTTPS redirect setup and verification — 1–2 hours.