]> _ Git - nec-initiative-wordpress.git/commitdiff
Set up HTTPS and canonical domain redirections. Done #4564 @0.25
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 12 Aug 2021 13:19:10 +0000 (15:19 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 12 Aug 2021 13:19:10 +0000 (15:19 +0200)
.htaccess

index 77d4f3458ab14569089632f0c46db3a2e77b5802..1130147a8f7e2c323c5ff489b7712613b32f72d5 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -1,3 +1,12 @@
+# Force HTTPS + redirect to non-www subdomain
+# Ref: https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/
+<IfModule mod_rewrite.c>
+RewriteEngine On
+RewriteCond %{HTTPS} off [OR]
+RewriteCond %{HTTP_HOST} ^www\. [NC]
+RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
+RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
+</IfModule>
 
 # BEGIN WordPress
 # The directives (lines) between "BEGIN WordPress" and "END WordPress" are