Redirect to www from non www

Hi there,

with cloudflare pages when not using www it is very easy to simply add AAAA record with like this:

AAAA www 100::

But I am not able to understand what to do in the opposite scenario.

I am using a website with www. now if I visit http://example.com it redirect the visitor properly to https://www.example.com but if user visits https://example.com it does not redirect the user.

what is the solution here?

thanks

Just a question? should I expect a response here as I saw so many posts without any answer. what is the trick to get the solution, cheers!

Hello,
I believe the current redirect is standard in Cloudflare, because it transitions from http to https.
However you can add new redirects. Please verify if this link is helpful Single Redirects — Example rules · Cloudflare Rules docs

Hope it helps

1 Like

Hi @chora

Thank you for the response but the solutions from that page doesn’t work for me. I have page rules but still nothing. so here is the full picture:

Cloudflare pages custom domain uses the domain as www.example.com

1st page rule: example.com/* Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://www.example.com/$1)

2nd page rule: https://example.com/* Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://www.example.com/$1)

Now here are the redirects which are working:

http://example.com properly redirects to https://www.example.com

http://www.example.com properly redirects to https://www.example.com

But the issue with https://example.com remains as is, it does not redirect to the https://www.example.com

I am not able to understand what needs to be done, the documentation fail to address this part there is clear documentation on how to simply use AAAA www 100:: for www to non www but no clarity on what is the process for non www to www redirects for cloudflare pages :frowning:

Thanks

What is the real domain? What DNS records have you set for the apex and www? What page/redirect rules have you set? (Can you show a screenshot?)

Hi @sjr

the example.com is used for anonymisation but the records are these ones here:

Thanks

I’m not sure what you’ve done already (there’s no DNS record for the apex domain in your screenshot), so starting from the beginning if you want to redirect from the apex domain to www then you need to do this…

Create a redirect rule here…
https://dash.cloudflare.com/?to=/:account/:zone/rules/redirect-rules

Copy this example exactly, just changing the host names…

Then you need to create a DNS record for @ in your Cloudflare dashboard…
https://dash.cloudflare.com/?to=/:account/:zone/dns/records

Add a proxied dummy value of A 192.0.2.1 or AAAA 100:: for @.

You obfuscated the domain so I can’t test it.

1 Like

Thank you it worked, so what I needed to have was a redirect for @

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.