完全假冒的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]