为什么domain.com 上的网站无法运行,而www.domain.com 上的网站却可以?
这是工作页面:game on glove dot com
非工作页面是相同的 URL 减去“www.”。
现在尝试单击 YouTube 视频左侧页面左上角图库中的项目。他们在一个版本中弹出一个灯箱窗口,但在另一个版本中则不会。
另请尝试单击“单击此处订购”按钮。两个版本的网页中都会出现一个弹出窗口,但是一旦您做出选择,然后单击该灯箱窗口上的按钮,您将在 domain.com 版本上看到错误,但在 www.domain.com 版本上不会看到错误。
我错过了一些可笑的事情吗?
Here is the working page: game on glove dot com
The non-working page is the same URL minus the "www.".
Now try clicking on the items in the gallery at the top left of the page to the left of the youtube video. They pop a lightbox window in one version but not the other.
Also try clicking the "click here to order" button. A popup appears in both versions of the webpage, but once you make your selection and then click the button on that lightboxed window, you will see an error on the domain.com version, but not on the www.domain.com version.
Am I missing something ridiculous?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
单击“Click To Order”按钮时,您将返回 302 重定向状态,其中包含指向 www 的位置,由于 同源政策
下面的屏幕截图
When clicking the "Click To Order" button you return a 302 redirect status with a location to the www which your ajax call cannot follow due to the same origin policy
Screenshot below
由于该对象是闪存,因此它需要一个策略文件来拥有执行 javascript 代码的权限。它可能是从 www.don 加载的,不希望该页面在网站domain.com 下被索引得如此之好,而不是从domain.com 索引,这会破坏其跨域策略,因为它们不被视为同一域。因此,您必须更改跨域策略文件以包含所有子域
示例应该是(如果我没有记错的话):
Since the object is flash it needs a policy file to have permissions to execute javascript code. And it might be being loaded from www.don't want this page being indexed so well under the website domain.com as opposed from domain.com which would break its the crossdomain policy as they are not considered the same domain. So you have to change the cross domain policy file to include all subdomains
Example should be (if im not mistaken):
问题是因为处理请求的domain.com 后端脚本会在没有 www 的情况下发送 302 Moved Temporarily 请求。
我不确定 jQuery ajax 实现是否尝试遵循 302,但即使这样做,它也无法获取内容,因为它位于不同的域上,因此受 同源策略
最简单的解决方案是更新后端处理脚本以删除 302 重定向。或者,强制将所有流量从 http://domain.com 重定向到 http://www.domain.com
The problem is because the domain.com backend script that processes the requests sends a 302 Moved Temporarily if it's requested without the www.
I'm not sure if the jQuery ajax implementation tries to follow the 302 or not, but even if it did, it wouldn't be able to fetch the content because it's on a different domain and so is subject to the same origin policy
The easiest solution would be to update the backend processing script to remove the 302 redirect. Alternatively, forcefully redirect all traffic from http://domain.com to http://www.domain.com