Question

Cannot resolve non-www domain however www-domain works perfectly fine

Posted October 28, 2020 110 views
ApacheGetting StartedDNSInitial Server Setup

I have a digitalocean droplet setup with the LAMP droplet and have set this up to the URL www.gavk.co.uk - it loads fine if I include the ‘www’ in the URL but if I remove the 'www’ it never loads.

Here is my virtual hosts entry in the conf file

<VirtualHost *:80>
    ServerAdmin admin@gavk.co.uk
    ServerName gavk.co.uk
    ServerAlias www.gavk.co.uk
    DocumentRoot /var/www/gavkcouk/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml >
    </IfModule>
</VirtualHost>

When I ping gavk.co.uk from the terminal I get the error ping: cannot resolve gavk.co.uk: Unknown host (but works fine if I ping www.gavk.co.uk)

Below is the DNS and A records that I have setup in the digitalocean control panel (see the image link below) so I have the 3 nameserver entries and then the 2 A records (I have added two as I want to setup certbot and it recommends adding 2 A records one www and one non-www)

Image link of my A records

Can anyone suggest what I am doing wrong - I just want both gavk.co.uk & www.gavk.co.uk to resolve so they show the exact same webpage.

Thanks in advance

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hello @zabs

Looks like the issue is resolved or you were experiencing some temporary issue. The ping and curl to your domain gavk.co.uk work fine for me. You can clear the cache and check the functionality.

ping gavk.co.uk -c 4
PING gavk.co.uk (134.209.182.96): 56 data bytes
64 bytes from 134.209.182.96: icmp_seq=0 ttl=55 time=193.036 ms
64 bytes from 134.209.182.96: icmp_seq=1 ttl=55 time=157.177 ms
64 bytes from 134.209.182.96: icmp_seq=2 ttl=55 time=156.103 ms
64 bytes from 134.209.182.96: icmp_seq=3 ttl=55 time=158.923 ms

--- gavk.co.uk ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 156.103/166.310/193.036/15.463 ms
curl -I https://gavk.co.uk/
HTTP/1.1 200 OK
Date: Wed, 28 Oct 2020 18:23:21 GMT
Server: Apache/2.4.41 (Ubuntu)
Last-Modified: Tue, 27 Oct 2020 16:07:28 GMT
ETag: "9d-5b2a93e58384d"
Accept-Ranges: bytes
Content-Length: 157
Vary: Accept-Encoding
Content-Type: text/html

Cheers,

Dikshith

Submit an Answer