0

I am trying to point https://example.com to https://www.example.com

Because searching https://www.example.com loads the website with no issues, but searching https://example.com leads to an extremely long load time and then it just crashes to the screen where it says "website cannot be loaded / check proxy and firewall etc.

Is this an issue with the way the DNS has been setup? I set up 301 forwarding as well many days back but still having the same issues today.

HBruijn
  • 80,330
  • 24
  • 138
  • 209
  • Welcome to Server Fault! In your questions please refrain from using random domain names and use either your own domain or one of the RFC 6761 reserved domain names such as example.com, example.org or similar . Please refer to this Q&A for our recommendations with regards to how and what (not) to obfuscate in your questions. – HBruijn Jan 22 '24 at 17:38
  • I might help if you include how your dns zone is currently configured(anonymous). You can use digwebinterface.com for that – Turdie Jan 25 '24 at 02:23
  • Ot use dig ANY +noadditional +noquestion +nocomments +nocmd +nostats www.google.com. google.com. @4.2.2.2 Where you replace google.com with your domain – Turdie Jan 25 '24 at 02:32

2 Answers2

2

DNS can't forward, it can only alias (via CNAME). If you want forward, that's on your web server.

So, point example.com to your web server, using an A record (same IP address as www.example.com or a totally different server) and then configure the web server to forward from the bare domain to www.

As @Zdenek has reminded me, you can't put a CNAME on a bare domain.

HBruijn
  • 80,330
  • 24
  • 138
  • 209
Zac67
  • 11,547
  • 2
    A naked domain.com can never be CNAME, it's stuck with a direct IP specification via A/AAAA records. It's because historically, CNAME has to be the only record while the naked domain requires other records, more here: https://serverfault.com/questions/576130/using-a-cname-to-forward-traffic-from-a-naked-domain – Zdenek Jan 22 '24 at 17:07
  • @Zdenek Absolutely - what was I thinking?... – Zac67 Jan 22 '24 at 17:16
  • 1
    And to state the (not always for everyone) obvious redirecting HTTPS URL's requires valid certificates that include all domain names – HBruijn Jan 22 '24 at 17:43
1

Yes, this could be an issue with your DNS setup.

The habitual practise is set up the root domain as A type record, and the www as a CNAME type record pointing to @ or root domain.

If you have set up 301 redirect, ensure they are configured from example.com to www.example.com (subdomain) if you want to use www as default domain.

Also from the server side, check if you're using the .htaccess file to redirect requests from example.com to www.example.com in case to use Apache, a properly server block configuration for Nginx webserver.

HBruijn
  • 80,330
  • 24
  • 138
  • 209
mrexojo
  • 126
  • And to state the (not always for everyone) obvious : redirecting HTTPS URL's requires valid certificates for all used domain names, so for both example.com and www.example.com – HBruijn Jan 22 '24 at 17:45
  • "set up the root domain as A type record, and the www as a CNAME type record pointing to @ or root domain" - might be habitual for you, but it is BAD practice. As per discussion elsewhere the apex/bare/null DNS records have specific rules which restrict what you can do with them. Working with multiple hosts, geo-aware DNS, 3rd party CDNs becomes a lot more difficult. The www. record should be the canonical hostname and the webserver at the apex should redirect there. – symcbean Jan 23 '24 at 12:15
  • @symcbean You can use www. as the canonical address for the website and still CNAME it to the base domain in the DNS. One has nothing to do with the other and it is not bad practise. – Bachsau Jan 25 '24 at 01:23
  • "Working with multiple hosts, geo-aware DNS, 3rd party CDNs becomes a lot more difficult." – symcbean Jan 25 '24 at 09:55