I have set up CDN on Cloudways and was given a CDN Url. This I understand I need to add to my web application built on CodeIgniter.
I tried what solutions I could find on the web but it's either I'm not doing it right or it simply does not work.
I created a new helper file (cdn_helper.php) in my controller folder
function cdn_base_url($uri)
{
$currentInstance =& get_instance();
$keybasedcdnUrl = $currentInstance->config->item('cdn_based_key_url');
$extensions = array('css', 'js', 'jpg', 'jpeg', 'png', 'gif','pdf');
$pathParts = pathinfo($uri);
if (!empty($keybasedcdnUrl) && in_array($pathParts['extension'],$extensions)) {
return $keybasedcdnUrl . $uri;
}
return $currentInstance->config->cdn_base_url($uri);
}
Then I added this line to my config file
$config['cdn_based_key_url'] = '457224-1431795-raikfcquaxqncofqfm.stackpathdns.com';
It didn't work. What am I doing wrong?