使用htaccess的与CDNhtaccess、CDN

2023-09-02 00:54:58 作者:我宣你你造吗

我的现有开发的网站图片的网址为 http://domain.com/assets/

My existing developed site image url is http://domain.com/assets/

在present我们要使用CDN上拉

at present we want to use CDN with pull

我的CDN图片的网址为 http://cdn.cdndomain.com/

my CDN image url is http://cdn.cdndomain.com/

如何使用CDN对我现有的网站。我们不希望改变现有的HTML图像路径。如何重写与的.htaccess

how to use cdn for my existing site. We dont want to change existing html image paths. how to rewrite with .htaccess?

推荐答案

尝试把给你的domain.com文档根目录的.htaccess:

Try to put this to your domain.com document root .htaccess:

RewriteEngine On
RewriteBase /
RewriteRule ^assets/(.*)$ http://cdn.domain.com/$1 [L,R=301]