CDN Module and Canonical Domain
If by static resources you mean resources for which the content is served from the server, using the content of a file, then hook_page_build() is not invoked for such resources.
It's the server that handles those requests, and Drupal doesn't do anything. In that case, you could edit the .htaccess file to redirect the users to the right domain.

That is what I would do also in the case it's Drupal to produce the content. Rather than letting Drupal produce the output, and redirect the user to the correct sub-domain, where the output would be produced again, I would rather redirect the user once it is clear what type of resource is being requested, and which is the URL of the resource.