我已经使用CloudFront在joomla网站上设置了一个CDN插件。
一切似乎都很正常,除了来自CloudFront的所有请求都被重定向到网站域名的www版本。这似乎是由于非www -> www redirec规则造成的。
我已经根据这篇文章计算了CloudFront使用的IP范围:https://forums.aws.amazon.com/ann.jspa?annID=910
获取的网段如下:
HostMin: 54.239.128.1 HostMax: 54.239.191.254
HostMin: 54.240.128.1 HostMax: 54.240.191.254
HostMin: 204.246.168.1 HostMax: 204.246.171.254
HostMin: 204.246.174.1 HostMax: 204.246.175.254
HostMin: 204.246.176.1 HostMax: 204.246.191.254
HostMin: 205.251.192.1 HostMax: 205.251.223.254
HostMin: 205.251.249.1 HostMax: 205.251.249.254
HostMin: 205.251.250.1 HostMax: 205.251.251.254
HostMin: 205.251.252.1 HostMax: 205.251.253.254
HostMin: 205.251.254.1 HostMax: 205.251.254.254
HostMin: 216.137.32.1 HostMax: 216.137.63.254
最后,我组合了以下RewriteCond,以阻止规则重定向来自CloudFront的请求:
RewriteCond %{REMOTE_ADDR} !^204\.246\.16([4567])\.\d{1,3}
RewriteCond %{REMOTE_ADDR} !^54\.2(39|40)\.(12[89]|1[3-8][0-9]|19[01])\.\d{1,3}
RewriteCond %{REMOTE_ADDR} !^204\.246\.(16[89]|17[01])\.\d{1,3}
RewriteCond %{REMOTE_ADDR} !^204\.246\.1(7[4-9]|8[0-9]|9[01])\.\d{1,3}
RewriteCond %{REMOTE_ADDR} !^54\.239\.(249|25[0-4])\.\d{1,3}
RewriteCond %{REMOTE_ADDR} !^205\.251\.(19[2-9]|2[01][0-9]|22[0-3])\.\d{1,3}
RewriteCond %{REMOTE_ADDR} !^216\.137\.(3[2-9]|[45][0-9]|6[0-3])\.\d{1,3}然而,它似乎不起作用,CloudFront请求仍然被重定向到网站的www版本。
有谁有什么建议吗?谢谢!
发布于 2013-03-22 13:51:51
添加"www“和非"www”主机名作为Cloudfront发行版的源。摆脱重写规则。这应该可以解决您的问题。
https://stackoverflow.com/questions/15560860
复制相似问题