In the DNS we have an A record for www pointing to the ip address.
You will also need an A
record for the domain apex pointing to the same IP address. Or, preferably, an A
record for the domain apex pointing to the IP address and a CNAME
record for the www subdomain pointing to the domain apex.
You can then implement a standard non-www to www 301 redirect in the .htaccess
file associated with the WordPress installation. For example, at the top of the relevant .htaccess
file:
# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
The above will redirect any request where the requested Host
does not start www.
and prefix the www.
subdomain via a 301 (permanent) redirect.
Test first with a 302 (temporary) redirect and make sure you have cleared your browser cache before testing, since the earlier (erroneous) 301s (by Godaddy) are likely cached.
NB: I’ve used https://
in the above, but I notice you are using plain http
thoughout your question?