I need HTTPS for security and because it's a browser standard and I need a CNAME DNS record and a www
wildcard redirect in my .htaccess file for a certain CDN.
I get about 2 seconds delay in a Google Page Speed Insights (GPSI) test due to not avoiding the following multiple redirects:
http://example.com
(630 ms) →https://example.com
(480 ms) →http://www.example.com
(630 ms) →https://www.example.com
(480 ms) →
How to avoid multiple redirects in a Content Management System (CMS) agnostic way?
Update
- I think that the HTTP to HTTPS redirect was automatically created by LetsEncrypt.
- I did create the following wildcard redirect in my
.htaccess
file after being instructed to do so by a hosting provider's staff member:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]