UPDATE: Removing the rule below solves the unnecessary redirection. Now it just works fine. Though it is still reachable from two places, a canonical header solves the duplicate issue i guess.
I configured my site to have a static sub-domain like static.example.com. In this sub-domain's nginx config i have this:
if ($request_uri !~* "\.(jpe?g|gif|css|png|js|ico....)$") {
rewrite ^(.*) https://www.example.com$1 permanent;
break;
}
From W3 Total Cache panel i activated CDN to "Generic Mirror" and put the static.example.com as my CDN.
Now the images and css-js files in my site seems to come from the static subdomain. So far so good. But i can reach them from the example.com too. How can i prevent example.com to see the static content?
And also how can i disable access to the dynamic content from sub-domain?