I've found a few answers but none of them seem to be able to answer my problem. On my server we use non-www for asset serving and www subdomain is cnamed to our bigcartel store. What I'm trying to do is serve files from the non-www page if file is found, else redirect to the www subdomain with original request.
eg: redirect domainname.com/product-name
to www.domainname.com/product-name
because it doesn't exist on our asset server.
I've tried the following; but I've had no luck.
RewriteEngine On
RewriteBase /
# do not do anything for already existing files
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP_HOST} ^domainname\.com [NC]
RewriteRule (.*) http://www.domainname.com/$1 [R=301,L]