Background
I've added an SSL cert using Lets Encrypt/Certbot on my Debian 9 (Stretch) host.
To modify my Apache configuration, essentially certbot copies the vhost.conf file, wraps it with and inserts Include, SSLCertificateFile and SSLCertificateKeyFile entries.
And the old HTTP vhost.conf file is modified to simply redirected to HTTP to HTTPS using Rewrite rules.
I am happy for the site to be HTTPS for all end-users, but there may be circumstances where I would like a PHP script to be able to request something from localhost via HTTP, and forcing those requests to use HTTPS when the traffic is entirely local seems unnecessary.
For the purposes of this question, I have reverted the old HTTP vhost.conf file so it will serve HTTP traffic as before.
Question
So my question is, if I put this in my HTTP vhost file, will it work correctly?
<If "%{req:Upgrade-Insecure-Requests} == '1'">
Redirect permanent "/" "https://mydomain.ltd/"
</If>
From my testing, it certainly appears to work 100% correctly, but my concern is that I am new to SSL and whilst it is broadly straightforward, there's a lot of potential for edge-cases where things might not work as intended.
Further Wittering
I like my proposed solution as it should redirect all users with a modern browser to use HTTPS without entirely preventing HTTP access. I also prefer using Redirect permanent
over rewrite rules as it's simpler, and presumably more efficient. But again, the fact that rather a high proportion of advice on the internet suggests using the rewrite method is slightly troubling!
UPDATE 2019-08-20 Just to clarify, by "work correctly", I mean the site will be accessible to all and, for most users, serve content via HTTPS.
I specifically want to avoid any issues that might prevent some users from being able to use the site.
Probably worth me mentioning that the site(s) I'm dealing with are basic brochureware sites that don't especially need SSL to be used safely.