0

I have a freshly built site on Wordpress, everything was fine until I decided to add WWW before the site name. I did it in WP and it worked, but GTmetrix measured some loading delays due WP redirects. So I decided to get rid of the WP redirects and change DNS records to make WWW by default so WP doesn't have to redirect anything. And yes, it worked! GTmetrix is happy, I was too but just for a couple of hours, because later that day I found that site doesn't load without WWW prefix. It works in Firefox (I guess FF adds www to anything in address bar), but not in Opera for example and also GTmetrix couldn't find it later.

What I did in DNS settings.

Before it was like this:

Type   | Name | Data         | 
-----------------------------
A      |  @   | ipv4 address |  
CNAME  | *    | example.com. |

One thing I changed is replacing @ with www

Type   | Name | Data         | 
-----------------------------
A      |  wwww  | ipv4 address  |  
CNAME  |  *     | example.com.  | 

How to make it work with and without WWW? Add another record? Thank you!

  • 1
    You should not remove the `@` entry, now `example.com` will [most probably not resolve at all](https://serverfault.com/questions/83874/whats-the-meaning-of-in-a-dns-zone-file). Apart from that, that's `wwww` in your entry, not `www` (4 `w` instead of 3). However, have you checked if `www.example.com` actually resolves to a different IP than `example.com`? If not the problem is not in DNS, but in your server configuration. – Gerald Schneider Apr 06 '20 at 07:22

1 Answers1

1

You need to have the @ record, otherwise requests to example.com will not resolve to anything.

The way I would set it up would be as following:

Type   | Name   | Data          | 
---------------------------------
A      |  @     | ipv4 address  |
CNAME  |  www   | @             |  
CNAME  |  *     | @             | 
Frederik
  • 3,293
  • 3
  • 30
  • 46
  • What's the point of the `www` entry? it's already matched by `*`. The original entries were fine, the problem most probably lies somewhere else. – Gerald Schneider Apr 06 '20 at 07:28
  • @GeraldSchneider None really, other than the fact that if you suddenly decide to point `*` to somewhere else, it doesn't affect the `www` record. It gives some clarity to how it is configured if someone else comes in and takes over the administration of the domain. – Frederik Apr 06 '20 at 07:33
  • @Frederik Nielsen Thank you, just changed the settings, I'll let you know tomorrow if it works. – DummyOne Apr 06 '20 at 07:49
  • Didn't help much. Basically it works as before (initial settings). Yes domain without www redirects to www.domain but gtmetrix says too much redirects. – DummyOne Apr 07 '20 at 13:09