From e22476da57708da98a75a559aed9fd6d54d07fac Mon Sep 17 00:00:00 2001 From: Alex Assistant Date: Thu, 19 Feb 2026 18:00:35 +0300 Subject: [PATCH] Fix redirect loop: robust HTTPS + non-www rules --- .htaccess | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.htaccess b/.htaccess index 144290c..f56c1ea 100644 --- a/.htaccess +++ b/.htaccess @@ -1,9 +1,10 @@ RewriteEngine On -# Force HTTPS -RewriteCond %{SERVER_PORT} !^443$ -RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] +# If behind reverse proxy (some shared hostings), trust X-Forwarded-Proto +RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC] +RewriteCond %{HTTPS} !=on +RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] -# Force non-www +# Force non-www on already HTTPS URL RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]