如何使用AWS Amazon Cloud将非WWW转发到WWW前面的HTTPS云前端 [英] How to forward non WWW to WWW with AWS Amazon Cloud front behind HTTPS cloud front

查看:370
本文介绍了如何使用AWS Amazon Cloud将非WWW转发到WWW前面的HTTPS云前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Cloud Front,可以将所有呼叫重定向到HTTPS协议。
现在我想将非www转发给www。如何在当前设置方面实现这一目标?

I already have Cloud Front setup to redirect all calls to HTTPS protocol. Now I want to forward "non www" to www. How can I achieve this with respect to the current setup?

我尝试了下面的那个,但是没有成功,因为这个没有考虑HTTPS重定向。

I tried the one below, but it wasn't successful as this one doesn't take HTTPS redirection into consideration.

https://www.pbxdom.com/how-redirect-non-www-to-www-with-amazon-cloud-front-route-53-and -s3

网址不会重定向www。相反,它显示错误消息:
此XML文件似乎没有与之关联的任何样式信息。文档树如下所示。

URL doesn't redirect www. Instead, it shows error message: This XML file does not appear to have any style information associated with it. The document tree is shown below.

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>


推荐答案

这是解决问题的另一种方法。我实际上试图完成你所做的事情,当涉及到CloudFront时,我似乎永远无法将非wwww重定向到www。

Here's another way of solving the problem. I actually tried to do exactly what you did, and I could never seem to truly redirect the non wwww to the www when CloudFront was involved.

将CloudFront设置为重定向后所有HTTP到HTTPS,它处理所有重定向,所以你不必担心它。你可以把它从逻辑方程中拿出来。

Once you set CloudFront to redirect all HTTP to HTTPS, it handles all of that redirection so you don't need to worry about it. You can take it out of the logic equation.

您的Route 53中应该有4个A类型的记录(假设您在CloudFront中启用了IPv6):

You should have 4 "A" type records in your Route 53 for the domain (assuming you have IPv6 enabled in CloudFront):


  • www.domain.comA别名记录指向您的CloudFront实例

  • www.domain.comAAAA别名记录指向到您的CloudFront实例

  • domain.comA别名记录指向您的CloudFront实例

  • domain.comAAAA别名记录指向您的CloudFront实例

  • www.domain.com "A" alias record pointing to your CloudFront instance
  • www.domain.com "AAAA" alias record pointing to your CloudFront instance
  • domain.com "A" alias record pointing to your CloudFront instance
  • domain.com "AAAA" alias record pointing to your CloudFront instance

最后,在常规CloudFront配置的CloudFront备用域名(CNAME)字段中,确保它包含www和非www。请注意,CloudFront更改实际上需要花费很长时间才能传播,因此请谨慎对待您的更改。

And lastly, In the CloudFront "Alternate Domain Names (CNAMEs)" field in the general CloudFront configuration, make sure it contains the www and the non www. Do note that CloudFront changes actually take quite a while to propagate, so be deliberate and patient with your changes.

最终结果是www和非www将会工作,没有任何明显的重定向从非www到www,但仍然有HTTPS重定向。

The end result of this is that both www and non www will work, without any apparent redirection from non www to www, but there is still HTTPS redirection.

这篇关于如何使用AWS Amazon Cloud将非WWW转发到WWW前面的HTTPS云前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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