使用 .htaccess 从 Amazon S3 CloudFront 访问服务器文件

发布于 2024-09-05 19:08:29 字数 567 浏览 7 评论 0原文

我理想的设置是获取当前的客户端站点,上传一个内部包含正则表达式的 .htaccess,该正则表达式将与 URI 匹配,如果它找到某个文件扩展名,它将使用相同的路径,但具有更改的域。

IE。

正常路径:

http://www.domain.com/something/images/someimage.jpeg
http://www.domain.com/assets/js/jquery.js

.htaccess 翻译后会将上面的内容变成:

http://mycdn.other.com/something/images/ someimage.jpeg
http://mycdn.other.com/assets/js/jquery.js

我连续几个小时在谷歌上搜索这个,没有运气。 再次强调,这是为了实际利用 Amazon 的 CloudFront。 S3 已经安装到网站上,用于使用 s3fs 进行备份和存储文件,但这并不能解决问题,因为它直接使用 S3,而不是使用 CloudFront。

My ideal setup would be to take a current clients site, upload a .htaccess with a regex inside, that would match the URI, and if it finds a certain file extension, it would use the same path, but with an altered domain.

ie.

Normal path:

http://www.domain.com/something/images/someimage.jpeg
http://www.domain.com/assets/js/jquery.js

.htaccess translated would turn the above into:

http://mycdn.other.com/something/images/someimage.jpeg
http://mycdn.other.com/assets/js/jquery.js

I googled this for hours in a row, no luck.
Again, this is for actually making use of Amazon's CloudFront.
S3 is already mounted to the website for backups and storing files using s3fs, but this doesn't solve the issue since it's using S3 directly, not using the CloudFront.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2024-09-12 19:08:30

您可以通过永久重定向轻松解决此问题。但这完全违背了使用cloudfront的目的。

Cloudfront 的理念是让您的用户始终获得靠近他们的快速服务器。如果所有的网址仍然必须通过您的服务器,那么您实际上已经使其速度变慢了。

您确定不能仅将链接更改为指向 cloudfront 链接吗?

You could easily fix this with a permanent redirect. But it would completely defeat the purpose of using cloudfront at all.

The idea of cloudfront is that your users always get a fast server close to them. If all the urls still have to go through your server, than you've actually made it slower.

Are you sure you can't just change the links to point to the cloudfront link?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文