I have created a brand new website in which I publish various computing services I suggest to potential customers.

As far as I know, no other website on the World Wide Web links to that website and today in nearly mid 2021 when people create backinks, they normally just make them "example.com" (no http:// or https:// and no www.).

After testing the website in Google Pagespeed Insights I got only one error about slow loading times due to the specific reason of four redirects:

http://example.com | 630 ms
https://example.com | 480 ms
http://www.example.com | 630 ms
https://www.example.com | 480 ms

While I need the www. for a CDN to protect from possible DDoS attacks and using HTTPS as a web standard, principally I would never create non HTTPS backlinks to my website and don't worry from anyone on the planet doing that.

Given the current HTTPS culture and my site being currently backlinkless, should I remove HTTP to HTTPS redirects to fix performance problems reported by Google Pagespeed Insights?

Update --- current .htaccess redirection directives

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
  • When you say there are four redirects, is that a redirect chain where you hit the 1st, it redirects to the 2nd, then the the third, and finally to the fourth? May 20, 2021 at 17:57
  • @StephenOstermiller I think that this is what happens ; I am not 100% sure myself...
    – RAMOS
    May 20, 2021 at 18:02
  • If it matters, my hosting is shared (namecheap, Stellar Business plan).
    – RAMOS
    May 20, 2021 at 18:02
  • If this is your redirect chain, then it is wrong to do it like that, as you switch from HTTPS to HTTP in the middle of things. You should stay in HTTPS all the time (and if possible collapse all redirects to just one). Other than that for anything new I think you shouldn't even bother to provide an HTTP version of the site, and just run out of port 443. May 20, 2021 at 19:04
  • @PatrickMevzek thanks, I wish I knew how to change my hosting partition to the scheme you have described; as this is a shared hosting environment I doubt that I have any control about this, but please allow me to update the question with an example of the current .htaccess redirect pattern.
    – RAMOS
    May 20, 2021 at 19:15

1 Answer 1


You should not remove HTTP to HTTPS redirects.

  • Removing them won't fix performance problems. Redirects only make it slower when users encounter them and most users should never see the redirects. Once a user is on your site (https://www.example.com/), all the links should keep the https and www. Users should never need the redirects once they are on the site.
  • Some other sites may be linking to you with http or without www. If you stop serving http those links would break.
  • Type-in traffic typically hits http before getting redirected to https. Users that type in "example.com" typically don't go straight to https. A few browsers can now be configured to try https first, but it isn't the norm yet.
  • If you are on shared hosting, you don't have the ability to turn off http. Shared hosting web servers are configured for http and https, there is no site-specific way to turn off just one of them. You could configure your site to serve an error for http, but you wouldn't be able to stop the webserver from responding to http requests.

The best thing to do is remove redirect chains. Your .htaccess rule currently has non-www traffic redirecting to http with the www. You should change it to redirect to https:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

It is usually desirable to also redirect http to https in the same rule:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule (.*) https://www.example.com/$1 [L,R=301]

You'd have to edit your site in place of example.com when using the rule.

  • Much thanks Stephen; I find this topic a bit confusing (why can't Apache PCRE be more simple and intuitive like Bash or modern JavaScript are?...)
    – RAMOS
    May 21, 2021 at 6:41
  • I understand the combined rule as: REDIRECT HTTP-NON_WWW, HTTP-WWW and HTTPS-NON_WWW to HTTPS-WWW is that correct?
    – RAMOS
    May 21, 2021 at 6:41
  • that is correct. It redirects any combination except for the desired one directly to the desired one. May 21, 2021 at 8:16
  • @RAMOS "why can't Apache PCRE be more simple and intuitive like Bash or modern JavaScript are?" - the regex engines used by Apache, Bash and JavaScript are all very similar. In fact, in the context of the directive above, they would be "the same". (Maybe you are not referring to regex, but to the syntax of the directives instead?)
    – MrWhite
    May 21, 2021 at 10:21
  • @RAMOS For simple needs, Apache RedirectX directives are enough, you should look at them instead of RewriteX. I never understood why everyone uses mod_rewrite for needs completely fulfilled by mod_redirect. May 21, 2021 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.