Too Many Redirects - CDN Rewrite Rule

toddlahman nginx-forum at
Thu Mar 21 02:47:39 UTC 2013

I have tried both ways to redirect my static files to a CDN (content
delivery network), but both ways result in the message "too many redirects."
Can anyone tell me what I am doing wrong here?

location ~* ^.+.(jpe?g|gif|css|png|js|ico)$ {
       rewrite ^$request_uri? permanent;
       access_log off;

location ~* \.(jpg|jpeg|gif|png|flv|mp3|mpg|mpeg|js|css|ico|woff)$ {
       return 301$request_uri;
       access_log off;

Posted at Nginx Forum:,237609,237609#msg-237609

More information about the nginx mailing list