wordpress wp-content/uploads folder 301 redirect to S3 bucket by cloudfrond CDN by .htaccess issues

Multi tool use


wordpress wp-content/uploads folder 301 redirect to S3 bucket by cloudfrond CDN by .htaccess issues
See below, the .htacess file from wordpress. If I remove the part starting from #begin Wordpress. All the image file url will be change to d28rt1vkpsdxas.cloudfront.net/someimage.png successfully.
However, all the internal link will be unable to access(only the home page can access). The error is
Not Found The requested URL /shop/ was not found on this server.
But if I keep the part start from #begin Wordpress. The cdn redirect will not work any more. All photos are missing.
Thanks in advanced.
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.