user1608354
user1608354

Reputation: 3

Need help rewriting static content to my CDN

I'm looking for help rewriting all the static content in one subdir over to my CDN URL. The tricky part is that I'd like this to happen whilest keeping the URL in the browser still showing my main URL. I also need to obviously keep it from rewriting requests from CloudFront to my server as well.

Here's what I have so far that I grabbed off another post when searching for some answers on this. Not sure what the HTTP:Via line is all about:

# Rewrite home page to launch countdown timer
RewriteRule ^$  /get-ready [L]

# Rewrite static stuff to CDN
RewriteCond %{HTTP:Via}   !\.s\.worldcdn\.com
# Flash wont work on cross-domain by default
RewriteCond $1            !^.swf$ [NC]
RewriteCond $1            "\.(jpe?g|gif|png|bmp|ico|js|css|pdf|docx?|xlsx?|ppt|rar|zip|tar|gz|tgz|bz2|flv|avi|mov|wmv|mp3|wav|xml|txt)$" [NC]
RewriteRule ^/get-ready/(.*)           http://cdn.domain.com/get-ready/$1 [L]

Thanks in advance!

Upvotes: 0

Views: 652

Answers (1)

BronzeByte
BronzeByte

Reputation: 725

The only way of keeping the URL is by proxying the content.
And by serving all files FROM a cdn THROUGH a single webserver destroys the entire idea of a CDN...

So please don't bother, also, you can use 301 Permanently Moved to make static files redirect to the CDN behind the scenes.

Upvotes: 1

Related Questions