I recently did a Google PageSpeed analysis of my website and received the following message:
Avoid landing page redirects
Your page has 2 redirects. Redirects introduce additional delays before the page can be loaded.
Avoid landing page redirects for the following chain of redirected URLs.
http://example.net/
https://example.net/
https://www.example.net/
Is there anything I can do about this (like modifying my htaccess file in some way), or is this an unavoidable consequence?
Here is my htaccess just in case:
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Yes. The redirection is an HTTP-level action which happens inside the SSL envelope. The client needs to establish an SSL connection to the original host before it 'sees' the redirect, then after completing the redirect it must establish another SSL connection to the target host.
Once you have SSL installed, you need to redirect visitors who are still accessing your old HTTP site to your new HTTPS site. You can redirect visitors to your HTTPS domain automatically—even when they try to use your old HTTP domain.
You can combine the two redirects into one by using the OR
flag
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With