Logan Best
Logan Best

Reputation: 501

Weird mod_rewrite behavior

I'm trying to redirect all specific file extensions to the CDN I have setup. Here's what I'm working with:

RewriteRule ^(.*\.(jpe?g|gif|bmp|png|css|js|txt|wmv|mp4|flv|avi|mov|wmv))$ http://cdn-w.domain.com/$1 [L,NC]

For some reason it's only redirecting to (for example http://www.domain.com/images/image.png)

http://cdn-w.domain.com/image.png

rather than

http://cdn-w.domain.com/images/image.png

Why is that?

Upvotes: 1

Views: 29

Answers (1)

anubhava
anubhava

Reputation: 784898

Try this rule:

RewriteRule \.(jpe?g|gif|bmp|png|css|js|txt|wmv|mp4|flv|avi|mov|wmv)$ http://cdn-w.domain.com%{REQUEST_URI} [R=301,L,NC]

Upvotes: 1

Related Questions