How to Enable CDN for Static Website

After create the CDN resources (here) , the CDN resources now is ready to use.


If the website is a static website, there is 2 method to enable CDN.


1) Replace the image url


If previous website source code as below


<img src="http://URL/images/logos/big.jpg" alt="" />
<img src="images/logos/big.jpg" alt="" />

 

It need to replace as below

 

<img src="http://cdn.youdomain/images/logos/big.jpg" alt="" />

 


2) If webserver do have Rewrite module enable, the rules as below could be apply

 

RewriteEngine ON
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 ^(.*) http://cdn.yourdomain/$1 [L,R]

 

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.