homepage Welcome to WebmasterWorld Guest from 54.198.130.203
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Setting up Images for a CDN (Content Delivery Network)
Need help with php coding.
trinorthlighting




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

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]

 

JD_Toims




msg:4604564
 1:04 am on Aug 24, 2013 (gmt 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) {
$image_source='http://cdn.example.com'.$this->src;
// The rest of what it is you do here to display an image
}

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved