0

So far, I have:

  • Registered a domain name with a registrar
  • Purchased a hosting plan with Hostgator
  • Updated the DNS records with my domain registrar with the values provided by Hostgator
  • Signed in to Hostgator portal and gone through the "Add-on domain" steps to add my domain name
  • Gone into the DNS control panel and reset the settings, then modified the CNAME record which shows the www subdomain so that its value is ghs.googlehosted.com
  • I have also updated the .htaccess file to include a 302 redirect for the root directory, to the Google Sites address
  • Have added the domain as a property within Google Sites, and added a TXT record in Hostgator to verify ownership (and Google is happy with that)
  • Configured Google Sites to serve my specific site for my domain

What happens when I punch my domain name into a browser is that I end up seeing the website, but the URL in the address bar updates to the Google Sites URL.

This suggests to me the CNAME record is being ignored and the .htaccess redirect is being applied.

Why would the CNAME record be ignored? These config changes were made 24 hours ago. When I "reset" the DNS settings in the Hostgator control panel, it produced a large number of other records, but note - I previously had this domain pointing to a different web hosting provider (named Format) and that was working. I backed up those domain settings and all looks similar - the only setting making any reference to "Format" was the CNAME record for WWW - so I should expect that if I simply changed that value to Google's address, it should work.

5
  • 1
    If you want DNS troubleshooting maybe start by giving the name involved? Also, there is nothing to wait as there is no propagation, with proper tools (dig) you can check immediately. Or use online tools like Zonemaster and DNSViz. – Patrick Mevzek Dec 22 '20 at 23:22
  • 1
    Thanks for the downvote, Patrick. Such encouragement. – youcantryreachingme Dec 22 '20 at 23:24
  • There are several things that need to be clarified here. What DNS records did you modify at your registrar? Are you modifying NS records there, or are you setting CNAME and A records there? Where is the DNS control panel, is that at hostgator? What does your 302 redirect point to, exactly. Your own www domain that is CNAMED to google sites, or to Google's domain? – Stephen Ostermiller Dec 23 '20 at 0:31
  • If you are hosting your site with Google sites, why are you using hostgator at all? Most registrars will do your DNS hosting for you. – Stephen Ostermiller Dec 23 '20 at 0:32
  • "Such encouragement. " You seem to have gone past the comment then. – Patrick Mevzek Dec 23 '20 at 14:53
1

After posting here I got in touch with a colleague who was able to resolve the issue for me - although I confess I don't fully understand why this works.

In a nutshell, when testing, I was keying in the domain name, without WWW, into the browser. In that scenario, the .htaccess file was being processed and my request was being forwarded with a temporary (302) redirect to the Google Sites URL.

What didn't make sense to me was that the .htaccess file was being processed "before" the CNAME record - but there's two points to note here: my request without WWW never engages that CNAME record, and secondly, you can use .htaccess to set up your web server so that regardless of whether end-users request using http or https, with or without the WWW subdomain, you can point all such requests to one "canonical" reference. The code I used is below, and all combinations of these requests will resolve to a request using https and the WWW subdomain. Of course, with the subdomain in the request, the CNAME record is then engaged and the site works as desired - displaying the Google Sites website while retaining my domain name (with https and WWW) in the address bar.

# Canonical https/www
<IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
    RewriteRule (.*) https://www.%1/$1 [R=301,L]
</IfModule>

And to Patrick, who downvoted the question because I didn't give the domain name, that is how you answer a question which is posed generically. Cheers to my mate Dan.

3
  • "I don't fully understand why this works." Without the name involved, noone can explain anything to you. Hence you achieved two things: next time you will have the exact same question because as you say yourself, you don't understand why it works and for future readers coming to this question your question and answer do not help at all as they severily lack context and details. The aim of this site is not just to answer your question but to build a corpus of good questions and good answers that help in the future. Your case does not. – Patrick Mevzek Dec 23 '20 at 14:55
  • Things like "What didn't make sense to me was that the .htaccess file was being processed "before" the CNAME record" utterly makes no sense at all. As you mix things coming from completely different parts of the system. The webserver (where the .htaccess file comes into play) has absolutely no idea how you reached it, if it was through a CNAME or any other record. – Patrick Mevzek Dec 23 '20 at 14:55
  • "that is how you answer a question which is posed generically" No, it is NOT. There is nothing useful in this reply for future readers. – Patrick Mevzek Dec 23 '20 at 14:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.