add www or http to domain on apache

Requests for example.com work fine, but www or http://www do not resolve. I am using anycast dns from domain provider. I am not certain this is a apache issue. Should I add an A record @www.example.com pointing to server ip? Or is there a redirect issue on the server itself. I am a beginner level technician.


Solution 1:

Your issue is with DNS. Yes, you should add and simple A record so that the www prefix also resolves to the same ip address as example.com

Example from my local DNS:

;
; BIND data file for smythies.com
;
$TTL    604800
@       IN      SOA     smythies.com. doug.smythies.com. (
                        2021031901      ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
                IN      A       192.168.111.1
;
@               IN      NS      ns1.smythies.com.
ns1             IN      A       192.168.111.1
www             IN      A       192.168.111.1
s15             IN      A       192.168.111.1
test            IN      CNAME   ns1
mail            IN      CNAME   ns1
Wireless-R      IN      A       192.168.111.57
dwifi           IN      A       192.168.111.58
doug-xps        IN      A       192.168.111.100
...