Needing help with redirecing non-www to www

Hello,

I’m having trouble forwarding mywebsite .com to www.mywebsite .com. Accessing my website via www.mywebsite .com works just fine.

My setup is a bit complicated: I’m using a google site, a domain from netcup and DNS from cloudflare.

I followed everything in this guide: https://community.cloudflare.com/t/redirect-example-com-to-www-example-com/78348

I have one DNS entry, type A, from the root (@) to 192.0.2.1. Then I have a CNAME one for pointing the www to google, but I think that’s irrelevant.
Page rules are set up too: mywebsite .com/* is being forwarded to www.mywebsite .com/$1, just like in the guide.

Can anyone help me what the problem is?

Hi @koelnerfahrradclub,

Thanks for checking out the tutorial! Can you share the domain you are having issues with?

Sure! It’s koelnerfahrradclub.de / www.koelnerfahrradclub.de :slight_smile:

Thanks!

That redirect seems to be working OK for me:

curl -I koelnerfahrradclub.de   
HTTP/1.1 301 Moved Permanently
Date: Wed, 01 Dec 2021 20:53:13 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Wed, 01 Dec 2021 21:53:13 GMT
Location: http://www.koelnerfahrradclub.de/
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=SCEVV3%2B%2BMKaPABVKKE1u83lYZG%2BFnzvIr%2FaVzM23l22R7auiaq%2FMrQCyH318P6B83TXPTJzYZ7wn1vPMRBwGaSe1F6jjQGfACaTnNzaqGU3TWEiZvcwZBxVy9l0DW9aiUN5WgWlkR9Q%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 6b6f3426ca2c76e3-LHR
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400

What do you see instead of the redirect? Is there an error page? I wonder if you have the DNS value for your root domain cached on your end.

I just cleared my DNS cache again, now the normal redirect is working fine.

For any pages on my website, the redirect doesn’t work tho. For example Kölner Fahrrad Club - Galerie, it shows me this error:
DNS_PROBE_FINISHED_NXDOMAIN

That’s my page rule configuration:

This one also works for me:

curl -I http://koelnerfahrradclub.de/galerie
HTTP/1.1 301 Moved Permanently
Date: Wed, 01 Dec 2021 21:02:14 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Wed, 01 Dec 2021 22:02:14 GMT
Location: http://www.koelnerfahrradclub.de/galerie
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=iikMhBL1qLkqgxGlp%2Bujd%2B3421LQz3e6IEUTCEEe3vJUvoDRq%2F5zZmA0v9SD3BsjPlPRXlXsu%2F1H3desenkSgOtkGXIuO%2BgAVxa%2FH7VJO8jokmN5aHiHK%2FWX4dA%2BP330mtxPj4xdQeI%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 6b6f415f0e2571ae-LHR
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400

This points towards your device / DNS Server caching the DNS record (or lack of one). The record is in place, so this should resolve itself locally for you.

All looks good. You may want to consider changing the bottom URL from http to https just to reduce the number of redirects, as it currently sends users to http://www and then https://www. Not essential, though.

I just tried visiting the website from my phone - it’s working perfectly! I guess I’ll just have to wait a bit on my PC until it’s working again. Thank you for the tip regarding the redirect, I’ll change that soon.
Also thank you for your help and time!

1 Like

No problem, glad it’s working for you somewhere at least! Let us know if you have any more problems/questions.

1 Like

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