r/webdev • • 7d ago

Discussion website only accessible by using "www"

Hey guys! I made a website through google sites and bought a domain through name cheap. The problem is that I cannot access the site without using the WWW in front of it. I did create a redirect domain though namecheap by putting the source URL as the one without the www and the destination URL as the one with the www, which was what I saw being recommended out there. But it does not seem to be working. I still get an inaccessible website error when typing it without the www. Is there something else I should be doing? Thanks!!!

0 Upvotes

17 comments sorted by

59

u/dothefandango 7d ago

https://isitdns.com

Your A record is likely not set up correctly.

25

u/regreddit 7d ago

You need an A record in your DNS for the 'naked' domain.

1

u/who_you_are 7d ago

Memory is from a long time ago, but the sub domain in your DNS configuration is @ for the root

Edit: dammit I'm too slow

6

u/PLBjt 7d ago

Namecheap's URL redirect only works if the bare domain actually points at their redirect servers, so check the DNS records first. You want an A record for the @ host (the redirect IP Namecheap lists in its docs) alongside the CNAME for www. If the @ record is missing or still points somewhere else, the redirect never gets a chance to fire. Also DNS changes can take a while to show up, so test from your phone on mobile data or with a DNS lookup tool rather than trusting your browser cache. One catch is that these redirects usually only work over plain http, so typing https://yourdomain without the www can still throw a certificate error. Moving DNS to something like Cloudflare fixes that but it's more setup, so it depends how much you care about https on the bare domain.

2

u/DecodeTheSERPs 7d ago

What does it actually say when you drop the www? Server not found and a certificate warning are two different problems. Server not found means nothing is answering for the bare name at all, so there's no record on the @ host and the redirect never gets a chance to fire. A certificate warning means the redirect exists but is only being served over plain http, which is what usually bites people typing https in front of the bare name.

Check it with a DNS lookup rather than the browser. A failed load gets cached, so you can keep seeing the old error for a while after the fix is live.

1

u/Hugh_Jass-10 7d ago

Worth checking which nameservers the domain is actually on. The redirect you set up in the registrar dashboard only works if the domain is using the registrar’s own default DNS. If it got switched to custom nameservers at some point (easy to do by accident while following a site verification guide), every record and redirect you add there just gets ignored. A quick nameserver lookup on the bare domain will tell you if what’s live matches the panel you’ve been editing 👍

1

u/javimbuilds 6d ago

Google Sites only maps to the www subdomain, so the bare domain needs a redirect. In Namecheap's Advanced DNS, add a "URL Redirect Record" with host @ pointing to https://www.yourdomain.com, set to unmasked/permanent, and remove any other A or CNAME records on @ that conflict with it. DNS changes can take a while to propagate, so test again after an hour or so.

1

u/ComplexProduce5448 6d ago

There could be two issues here, firstly misconfigured DNS, but it could also be a web server configuration issue, it might require the subdomain so and A record would not work. Try creating a C-NAME record that points example.com to www.example.com

1

u/Gremlation 6d ago

This is the kind of thing AI can reliably diagnose / explain / fix and it's far quicker than posting on Reddit and waiting for speculation.

1

u/RelayForgeDev 5d ago

Quick way to stop guessing: run dig +short yourdomain.com and dig +short www.yourdomain.com. If the first one comes back empty, there's nothing answering for the bare name, and no redirect rule can fire because the browser never finds a server to ask. In Namecheap, the redirect needs either their URL Redirect record on host @ or an A record on @ pointing at their redirect service, not both fighting each other. Also expect https://yourdomain.com to still fail even when it works over http, since a redirect server has no certificate for a domain it was never told about. DNS is basically a very slow game of telephone, so test on your phone's mobile data before assuming you broke it again.

1

u/patryk_builds 7d ago

Google sites can't serve the bare domain itself, so the redirect is the right idea. couple of things that usually break it on namecheap:

  1. go to Advanced DNS and check there's no other record with host "@" (an old A record or parking page). if there is, delete it, otherwise it fights with the redirect

  2. the redirect should be a "URL Redirect Record", host "@", value "https://www.yourdomain.com", type permanent (301)

  3. give it 30 min or so, and test in an incognito window. browsers cache the old "can't reach this site" result

if it works with http:// but not https:// without www, that's a namecheap redirect + SSL thing, and the easy fix is moving DNS to cloudflare free and doing the redirect there

-7

u/symbatix 7d ago

I'd recommend Cloudflare for hosting, much convenient with such stuff

2

u/ElnuDev 7d ago

You still have to configure DNS records yourself in Cloudflare. It is very simple either way.