Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 8 months ago.

Assisted by: Long Nguyen.

Author Posts
September 19, 2023 at 5:06 pm #14422817

robS-30

I have successfully installed and configured Bunny CDN and mapped it to ramset.com.au. The images and necessary files are loading from the Bunny CDN to the ramset.com.au website without any issues.

However, on ramset.co.nz, the images are not loading through the CDN. I need to configure Bunny CDN for ramset.co.nz. We have been able to create a separate CDN configuration, but we are facing difficulties in adding it for the NZ site. Could you please review and provide guidance on how to configure it for the NZ site?

September 20, 2023 at 9:06 am #14427879

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Rob,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

Please try the workaround below and let me know if it helps:

❌ IMPORTANT: Please backup your database and website before proceeding ❌
- Edit the file wp-content/plugins/bunnycdn/inc/bunnycdnFilter.php
- Around line 74-78, replace the code

// If this is NOT a relative URL
if (strstr($foundUrl, $this->baseUrl)) 
{
	return str_replace($this->baseUrl, $this->cdnUrl, $foundUrl);
}

with this one

// WPML fix
if (strstr($foundUrl, apply_filters('wpml_home_url', $this->baseUrl)))
{
        return str_replace(apply_filters('wpml_home_url', $this->baseUrl), $this->cdnUrl, $foundUrl);
}

- Around line 92, replace the code

$regex = '#(?<=[(\"\'])(?:'. quotemeta($this->baseUrl) .')?/(?:((?:'.$directoriesRegex.')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';

with this one

$regex = '#(?<=[(\"\'])(?:'. quotemeta($this->baseUrl) . '|' . quotemeta(apply_filters('wpml_home_url', $this->baseUrl)) .')?/(?:((?:'.$directoriesRegex.')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';

Look forward to your reply.
Thanks

October 3, 2023 at 1:03 pm #14504921

robS-30

As per your advice, we have made changes to the two codes on lines 74-78 and 92 in the staging site. However, I am still observing that the images and files for stg.ramset.co.nz are not being served from the Bunny CDN URL as expected. Please provide further guidance on the next steps to address this issue.
URL: hidden link

October 4, 2023 at 2:48 am #14509167

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I see images on both domains hidden link and hidden link are loading from CDN URL, screenshots hidden link

Can you please recheck this?

The topic ‘[Closed] Regarding CDN enabling for the New zealand domain’ is closed to new replies.