Welcome! Log In Create A New Profile

Advanced

Re: rewrite rule to send all static content to CDN?

June 13, 2009 01:02AM
On Fri, Jun 12, 2009 at 06:19:28PM -0500, Joe Shang wrote:

> With Apache we can do this using:
>
> RewriteCond %{HTTP_USER_AGENT} !^CDN_USER_AGENT$ [NC]
> RewriteRule .*\.(jpg|gif|png|flv|css|js|swf)$
> http://cdn-domain-name/$0 [R=301,L]
>
> But we want our CDN to serve our static content, what would be easier
> to accomplish this?
>
> I tried:
>
> rewrite ^/*\.(jpg|gif|png|flv|css|js|swf)$
> http://http.cdnlayer.com/contentfolder$1 last;
>
> But it didn't work.
>
> Should I be using a location instead?
>
> location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
> access_log off;
> expires 30d;
> }
>
> Like the above ones? but how would the rewrite portion come into play?

location ~* ^.+.(jpe?g|gif|css|png|js|ico)$ {
rewrite ^ http://http.cdnlayer.com/contentfolder$request_uri?
permanent;
access_log off;
}


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

rewrite rule to send all static content to CDN?

Joe Shang June 12, 2009 07:19PM

Re: rewrite rule to send all static content to CDN?

Igor Sysoev June 13, 2009 01:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 95
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready