如何将根域和子域都指向 Google Cloud Storage 存储桶? [英] How to point both root and sub domain to Google Cloud Storage bucket?

查看:16
本文介绍了如何将根域和子域都指向 Google Cloud Storage 存储桶?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功创建了一个托管在 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 子域而不是根.

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 记录,因为 Cloudflare 允许 CNAME 扁平化),但这在这里不起作用.

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 网站配置文档说:例如,对于example.com,CNAME 记录包含以下信息: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 存储端将 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/

https://support.cloudflare.com/hc/en-us/articles/200172286-How-do-I-do-url-forwarding-with-CloudFlare-

这篇关于如何将根域和子域都指向 Google Cloud Storage 存储桶?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆