完全假冒的URL以的.htaccess [英] Completely fake URL with .htaccess

查看:95
本文介绍了完全假冒的URL以的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提供静态内容与Amazon CloudFront的,并用我的服务器作为原点。

I am serving static content with Amazon CloudFront and am using my servers as the origin.

由于CF不尊重?查询字符串,我不能轻易强制CF使用的.png文件的新版本。我也需要快速的失效和不想支付无效宣告请求。

Since CF does not respect ? query strings, I can't easily force CF to use new versions of .png files. I also need fast invalidation and do not want to pay for invalidation requests.

所以,我想创建一个完全假的目录中的.htaccess给力版本的我的图片。

So I want to create a completely fake directory with .htaccess to force versioning for my images.

例如,我想:

domain.com/static/0.12/images/background.png

domain.com/static/0.12/images/background.png

domain.com/static/images/background.png

domain.com/static/images/background.png

0.12哪里是我的应用程序版本,它会通过我的部署脚本自动改变。

Where 0.12 is my APP version, which will be automatically changed through my deployment script.

什么是这样做的。htaccess的规则?

What would be the .htaccess rule for this?

推荐答案

如果你真正想要的网址

domain.com/static/0.12/images/background.png

domain.com/static/0.12/images/background.png

在内部重定向到

domain.com/static/images/background.png

domain.com/static/images/background.png

以下内容添加到您的站点根目录下的.htaccess文件。

Add the following to the .htaccess file in the root of your site.

RewriteEngine On
RewriteBase /

RewriteRule ^static/0\.12/images/(.+)$ static/images/$1 [L,NC]

如果该程序版本会有所不同,然后用

If the APP version varies then use

RewriteEngine On
RewriteBase /

RewriteRule ^static/[\.0-9]+/images/(.+)$ static/images/$1 [L,NC]

这篇关于完全假冒的URL以的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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