Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Setting up Images for a CDN (Content Delivery Network)

Need help with php coding.

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 5, 2006
votes: 2

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:




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)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:July 19, 2013
votes: 0

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) {
// The rest of what it is you do here to display an image