Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter Toutenrab

    (@toutenrab)

    I’m answering my own question, I’ve succeded to rewrite an URL to a CDN hosted URL:

    function rewrite_url_to_cdn_url($url){
        // check if W3 Total Cache is installed
        if(class_exists('W3_Plugin_Cdn')){
            $w3tc_instance = new W3_Plugin_Cdn();
            $path        = str_replace(site_url() . '/','', $url);
            $cdn         = $w3tc_instance->_get_common()->get_cdn();
            $remote_path = $w3tc_instance->_get_common()->uri_to_cdn_uri($path);
            $new_url     = $cdn->format_url($remote_path);
        } else {
            $new_url = $url;
        }
        return $new_url;
    }
Viewing 1 replies (of 1 total)