CDN, SEO and image styles: 301 on GET request Recently I installed the CDN module. To avoid duplicate content I added a RewriteRule to my Apache config:

RewriteCond %{REQUEST_URI} !(^/(.*)(.js|.css|.jpg|.jpeg|.gif|.png)) [NC]
RewriteCond %{HTTP_ACCEPT} !(.*image.*|.*css.*|.*javascript.*) [NC]
RewriteCond %{HTTP_HOST} ^(static1.domain.com|static2.domain.com)$ [NC]
RewriteRule ^(.*)$ http://domain.com$1 [L,R=301]


This is working, except when I'm using image styles. If the image exists everything works, but when it doesn't exist, I get a 301 to http://domain.com/index.php



These are the current situations using the implemented RewriteRule:


GET static1.domain.com - 301 to http://domain.com - OK
GET static1.domain.com/image.jpg - 200 - OK
GET static1.domain.com/sites/domain/files/styles/.../image.jpg when
file exists - 200 - OK
GET static1.domain.com/sites/domain/files/styles/.../image.jpg when
file doesn't exist - 301 to http://domain.com/index.php - WRONG


How do I force the image style file to be created when browsing to it from a static URL?
I dont really understand your question, but we handled a similar problem.
We also did rewrtie for all images to static server (different server running lighttpd).
On the lighttpd the files folder was mounted as well, so all files are in sync. 

We also had a domain that forced back to one of the webservers (varnish>drupal), and not to use the CDN server . 
If the file did not exist in the static server it got rewrtitten (temporary) back to the webserver, which created the imagecache file.
From that moment, the file was there and it would always be there.

attr = lighty.stat(lighty.env['physical.path'])
 if (not attr) then
 lighty.header["Location"] = "http://directto.webserver.com"  .. lighty.env["request.uri"]
 return 302
end


Hope this can help.