【问题标题】:Redirect Domain to Subdomain using Cloudflare使用 Cloudflare 将域重定向到子域
【发布时间】:2021-10-21 03:46:54
【问题描述】:

我正在使用营销自动化平台来构建登录页面,这些登录页面 URL 会自动发布并带有子域结构,例如:

https://subdomain.example.com/mylandingpage

我希望将对主域的所有 www 和非 www 访问重定向到我创建的这个登录页面,换句话说,我希望将 https://example.comhttps://www.example.comto 重定向到 https://subdomain.example.com/mylandingpage

由于我只使用这个平台并且没有订阅任何托管,我正在尝试使用 Cloudflare 进行所有这些重定向。

我看到一个教程,这家伙说我的 DNS 中的 A 条目不应该为空,并建议将它们设置为保留的 IP 地址,所以我将两个 A 条目都设置为 192.0.2.0。

好的,然后我转到页面规则并设置 301 重定向到 *example.com 以重定向到 https://subdomain.example.com/mylandingpage

我可以看到,当我访问我的主域时,它被正确地重定向到了子域,但是页面没有加载,并且我收到了太多重定向错误。我相信我做错了什么,它将所有内容重定向到子域,甚至子域也重定向到自身,甚至在主机名之后有一个页面路径 /mylandingpage。

我说清楚了吗?有没有其他方法可以做我想做的事?

【问题讨论】:

    标签: redirect dns http-headers cloudflare


    【解决方案1】:

    在 Cloudflare 页面规则而不是 *.example.com 中,请使用完全域匹配。

    我们可以使用通配符的URL路径。

    www.example.com/* - https://subdomain.example.com/mylandingpage example.com/* - https://subdomain.example.com/mylandingpage

    【讨论】:

      猜你喜欢
      • 2014-11-14
      • 2014-03-09
      • 2015-02-22
      • 1970-01-01
      • 2018-02-05
      • 2019-08-11
      • 1970-01-01
      • 2014-09-09
      • 2014-08-19
      相关资源
      最近更新 更多