Welcome to WebmasterWorld Guest from 54.163.168.15

Forum Moderators: coopster & jatar k

Setting up Images for a CDN (Content Delivery Network)

Need help with php coding.

   
12:34 am on Aug 23, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Ok, we have been working a lot on speeding up our website and have moved to a Content Delivery Network. Since we are using a cdn, our urls need to change from:

http://example.com/bmz_cache/etc....

to

http://cdn.example.com/bmz_cache/etc.

Now, we know that this code listed below is what we need to change, but are not sure how to change it in php and we are asking for some help here.


((strpos($this->src, substr($bmzConf['cachedir'], strlen($ihConf['dir']['docroot']))) === 0))) &&

Can anyone help us out here a bit on the coding? I know that src (is the url), but we need to change that to point to the cdn.mywebsite.com url instead.

[edited by: phranque at 1:14 am (utc) on Aug 23, 2013]
[edit reason] exemplified domain [/edit]

1:04 am on Aug 24, 2013 (gmt 0)

WebmasterWorld Senior Member Top Contributors Of The Month



Best guess here.

strpos($this->src, substr($bmzConf['cachedir'], strlen($ihConf['dir']['docroot']))) === 0

The preceding basically says: "if the current src string begins with the same thing as the 'directory-docroot'."

To me that sounds like a /sever-relative/url, so I'm not sure if the line you have is what you need to change, but I can't see enough of the code to be sure.

What you might do if you find the URLs are server relative is add a check before the line you posted to see if it's an image file [either by directory EG /images/ or extension EG .gif] and pre-pend the location with an absolute URL prior to the preceding line.

What I'm thinking is something like:

if(strpos($this->src,'/images/')!==FALSE) {
$image_source='http://cdn.example.com'.$this->src;
// The rest of what it is you do here to display an image
}
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month