Fix redirect loop: robust HTTPS + non-www rules
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
|
||||||
# Force HTTPS
|
# If behind reverse proxy (some shared hostings), trust X-Forwarded-Proto
|
||||||
RewriteCond %{SERVER_PORT} !^443$
|
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
|
||||||
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
|
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]
|
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
||||||
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
|
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
|
||||||
|
|||||||
Reference in New Issue
Block a user