It always is optimal and recommended by Google to have as few redirects as possible.
So if my page is hosted on:
I want to redirect all other options (
http & www ||
http & !(www) ||
https & !(www) ) to
HTTPS & www with just one single redirect.
It normaly just takes one single redirect for ALL options, but the one with
HTTP & !(www) as it would go like this:
http:// domain.de => https:// domain.de => https://www domain.de as it first have to resolve the SSL cert before hitting the application.
Also these redirects then are done on Serverlevel, not at CloudFlare.
Thats the reason why I implemented this PageRule:
This works fine, but as soon as you activate HSTS it will not redirect from http://domain.de to https://www.domain.de in one step, but again in two steps, as HSTS kicks in earlier and first redirects to HTTPS.
This is not optimal.
What I would like to have:
Redirecting ALL other options to the target within just one single redirect and this should be done on CloudFlare, as it will redirect faster the earlier it is done, and if done at CloudFlare its definitely faster compared to the case it would have to hit my server.
What exactly is the problem?
Just on one domain (HTTPS & www) this problem exists as this is the only possible (normal) usecase where we would have 2 redirects:
- HTTP => HTTPS
- !(www) => www
How to solve this problem?
Would be easy if CloudFlare would allow logical operators in their rewrite rules like:
So we could dynamically define one Rule for redirects which applies to ALL usecases, or if CloudFlare would provide one special additional redirect rule for the maindomain combined with www as this very often is the usecase to have a FQDN and not just a QDN, which in some cases makes sense.
Maybe there is even a way to modify the HSTS config so it (on the maindomain
http://domain.de) is not redirecting to
https://domain.de but to
But 2 redirects for this is not optimal.