I am currently trying to redirect all the .css and .js files in my wordpress to my CDN. I was using W3TC to perform this CDN operation but I realised that an authenticated user using the Wordpress Dashboard does not load their .css and .js files from the CDN. The problem lies with the WP-Admin files not being put on the CDN/accessed and I am not sure how to fix that. Hence, I thought of using .htaccess to perform this redirect to my CDN. Currently, I am trying this but it does not seem to be working...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example.com
RewriteCond %{REQUEST_URI} ^(.*)\.js$
RewriteRule ^/(.*)$ https://cdn.example.com/$1
[NC,NE,R=301]
</IfModule>