Preventing Canonical Redirect for CDN

This can not work in the way you want. If wordpress is on example.com then all the auto generated links will point to example.com even for pages that are on the CDN under the www.example.com domain. This will result that after the first page being served from the CDN many other pages will be served directly from wordpress.

  1. from inspecting the code, the code that does it is deep inside redirect_canonical so either you need to write your own redicrection and do something like

    remove_action(“template_redirect”, “redirect_canonical”);

    add_action(‘template_redirect’, ‘wpsr12150_redirect_canonical’);

    function wpsr12150_redirect_canonical() {
    // code without the www redirection
    }

but it is probably easier to handle it in an .htaccess file, for example make it always remove the www from incoming requests

  1. yes!