Currently if I type mysite[dot]com
or www.mysite[dot]com
it redirects to https://mysite[dot]com
However I want it to redirect to https://www.mysite.com
I have created page rule also but none of them is working.
First of all, it’s important to understand that in order for a page rule to work the DNS record that is in your page rule pattern (e.g. mysite.com
) must be orange-clouded in your Cloudflare DNS. If it is not, then Cloudflare will never receive that traffic, nor will it be able to redirect it.
I would recommend enabling “Always Use HTTPS” in your SSL/TLS settings, this will force all traffic automatically to HTTPS, then you can add the following:
URL Pattern: https://mysite.com/*
301 Forward To: https://www.mysite.com/$1
Since Always Use HTTPS forces traffic to HTTPS you don’t need a second page rule to capture HTTP.
Thank you for a quick reply. I have already orange clouded my DNS in Cloudflare. And I am using “Always use HTTPS”. And then added the rule that you have said. but when I type www.mysite.com it says this page is not working,
while when i type only mysite[dot]com it redirects to non-www and https.
OK - can you give the exact URL? It’s hard to troubleshoot without the specifics in this case.
OK, so this is an origin issue:
< HTTP/2 302
< date: Wed, 08 Aug 2018 10:29:43 GMT
< content-type: text/html
< set-cookie: __cfduid=d96c0ce6e3355db4ff83a83a97b615e3d1533724183; expires=Thu, 08-Aug-19 10:29:43 GMT; path=/; domain=.islatials.com; HttpOnly; Secure
< x-powered-by: PHP/5.5.9-1ubuntu4.25
< location: https://islatials.com/
< expect-ct: max-age=604800, report-uri="https://report-uri.Cloudflare.com/cdn-cgi/beacon/expect-ct"
< server: Cloudflare
< cf-ray: 44714db07f016a4f-LHR
You can see there that the origin is returning a HTTP 302 back to https://islatials.com/
. The clue here is the x-powered-by: PHP/5.5.9-1ubuntu4.25
header that tells me Cloudflare went to your origin to return this response.
You will need to disable this redirect on your origin server, then everything should work just fine.
For future reference, you can compare a response with/without Cloudflare using cURL which is a useful tool to help diagnose:
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.