如何将根域和子域都指向Google Cloud Storage存储桶? [英] How to point both root and sub domain to Google Cloud Storage bucket?
问题描述
我已经成功创建了一个托管在Google Cloud Storage上的静态网站.
I've successfully created a static website hosted on Google Cloud Storage.
存储桶名称类似于:www.example.com
The bucket name is like: www.example.com
我的www的CNAME记录指向c.storage.googleapis.com
and my CNAME record for www points to c.storage.googleapis.com
我已经使用Google网站站长工具验证了www和根域.
I've verified both the www and root domain with Google Webmaster Tools.
在Google网站站长工具上,我将www设置为主域(我不知道是否相关,但在此处的另一篇文章中看到了对它的引用),重要的是,我是从www子域而不是www.根.
On Google Webmaster Tools I have the www set as the primary domain (I have no idea if that's relevant, but saw a reference to it on another post here) and it's important that I serve the site from the www subdomain and not the root.
我可以正常访问www.example.com,但是无论我尝试使用我的根域,都只会出现<NoSuchBucket>
错误.
I can reach www.example.com fine,but no matter what I try with my root domain I only get the <NoSuchBucket>
error.
信息点:我的DNS由Cloudflare管理.当我使用Github页面托管静态网站时,我通常将根指向带有CNAME记录的www(根本没有A记录,因为
Point of information: My DNS is managed by Cloudflare. When I use Github pages to host static sites I typically point the root to the www with a CNAME record (and no A record at all because Cloudflare allows CNAME flattening), but that does not work here.
我尝试将根域指向带有CNAME记录的www,并尝试将其指向c.storage.googleapis.com.
I've tried pointing my root domain to the www with a CNAME record and tried pointing it to c.storage.googleapis.com.
步骤2的Cloud Storage网站配置文档表示:"For example, for example.com, the CNAME record contains the following information: www CNAME c.storage.googleapis.com
",但没有提到指向根域,但这必须是常见的要求.
The Cloud Storage website configuration documentation for Step 2 says: "For example, for example.com, the CNAME record contains the following information: www CNAME c.storage.googleapis.com
" but makes no mention of pointing the root domain, yet this must be a common requirement.
我意识到我可以用根域创建一个附加存储桶,并将其指向http中的www,但是似乎应该有一种使用DNS记录的方法.
I realize I could create an additional bucket with the root domain and point it to the www in http, but it seems as though there should be a way to do this with DNS records.
推荐答案
您无法在Google Storage上将example.com根域指向www.example.com存储桶.唯一的选择是将example.com重定向/转发到DNS提供商上的www.example.com:
There is nothing you can do on Google Storage side to point example.com root domain to www.example.com bucket. The only option is redirecting/forwarding example.com to www.example.com on your DNS provider:
在Cloudflare上检查以下链接以进行转发:
Check these links for forwarding on the Cloudflare:
https://blog.cloudflare.com/introducing-pagerules-url-forwarding /
这篇关于如何将根域和子域都指向Google Cloud Storage存储桶?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!