配置任何CDN来不管是什么网址已被要求提供只有一个文件 [英] Configuring any CDN to deliver only one file no matter what url has been requested

查看:234
本文介绍了配置任何CDN来不管是什么网址已被要求提供只有一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前工作在哪里,整个页面应该在HTML5 / JS来实现对工作的API / JSON的新项目。由于整个应用程序应该只由一个HTML文件(index.html的)和JS MVC应用程序(也许backboneJs)我想到的是关于搜索引擎优化和用户友好的URL。

I am currently working on a new project where the entire page should be implemented in HTML5/JS working against an API/JSON. Since the entire application should only consist of one HTML file (index.html) and a JS MVC application (maybe backboneJs) I am thinking about SEO and user friendly urls.

在那里,我遇到了

window.document.pushstate('','title','/url');

使用的HTML5功能的帮助下,我可以定义的URL没有真正离开或刷新页面。但是...我希望将应用程序部署到 CDN像亚马逊CloudFount 性能的原因,低费用。我不需要任何服务器基础设施(除了我需要的当然API)

With the help of that html5 feature I can define URLs without really leaving or reloading the page. BUT... I want to deploy the application into a CDN like Amazon CloudFount for performance reason and low expenses. I would not need any server infrastructure (besides the one I need for the API of course)

所以,我可以配置一个CDN(任何真正的CDN像AWS,天青,Akamai的)提供相同的HTML文件,不管是什么网址被称为

So can I configure a CDN (really any CDN like AWS, Azure, Akamai) to provide the same HTML file no matter what URL is called

http://www.example.com =>提供的index.html

http://www.example.com => delivers index.html

http://www.example.com/any_subpage =>提供的index.html

http://www.example.com/any_subpage => delivers index.html

等等...

这是工作的例子,你可以找到在 http://html5.gingerhost.com 。但该网页的创建者可以使用.htaccess文件或者熟悉的东西映射一切到同一个文件。我想提供一种在CDN中相同的功能。

an working example you can find at http://html5.gingerhost.com. But the creator of that page may use an .htaccess file or something familiar to map everything to the same file. I want to provide the same functionality in a CDN.

推荐答案

任何CDN应该定义一个原始服务器的能力。该服务器被联系由CDN服务的文件,如果边缘位置没有了。

Any CDN should have the capability of defining an origin server. This server gets contacted by the CDN to serve the file if the edge location doesn't have it.

好消息是,原始服务器可以是任何提供的网页,比如Apache,Nginx的,等等。这意味着你可以使用任何一种你希望重写规则。

The good news is that the origin server can be anything that serves web pages, such as Apache, Nginx, etc. This means that you can apply any kind of rewriting rules you wish.

如果你不希望自己建立的原始服务器,你可以看看的托管的(静态)网站上的S3 。最近他们推出了网页重定向这可能有助于你要服务于一个不同的别名相同的文件。如果做不到这一点,你可以看看重新定义标准错误文件,但我不敢肯定是否错误状态code仍将被发送。

If you don't wish to set up the origin server yourself, you could look at hosting your (static) site on S3. Recently they have introduced web redirects which may help you to to serve the same file under a different "alias". Failing that, you could look at redefining the standard error document, but I'm not sure whether an error status code will still be sent.

这篇关于配置任何CDN来不管是什么网址已被要求提供只有一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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