title: How can I redirect image 404 error on Amazon S3 to my own server
body: <p>Is it possible to redirect a 404 error on Amazon S3 server to my own server? Here's the case in my website:</p>
  
  <p>A user uploaded a file, called abc.jpg. I have a set of image types, such as crop or thumb.</p>
  
  <p>When someone access /img/abc.crop.jpg, the webserver check and look for the file /img/abc.crop.jpg. If they found it, webserver will throw the file.</p>
  
  <p>But when the program can't found that file, this .htaccess file will route it to a program:</p>
  
  <pre><code>RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [L]
  </code></pre>
  
  <p>So it will go to index.php/img/abc.crop.jpg, where the "img" controller/program will look for abc.jpg and generate a file called abc.crop.jpg on the img folder. So next time another user access the abc.crop.jpg, the program doesn't need to regenerate the file anymore.</p>
  
  <p>Now, when I am using the Amazon S3, I have to generate ALL the different sizes (crop, thumb, etc) one by one to avoid 404 error. The purpose of the above technique is to conserve space. I wanted the flow to be kept consistent with the current condition. Anybody have any idea on how to manipulate S3 404 error so that they'll redirect to my server? Ie. <a href="http://bucket.s3.amazonaws.com/img/abc.crop.jpg" rel="nofollow">http://bucket.s3.amazonaws.com/img/abc.crop.jpg</a> redirect to <a href="http://mysite.com/img/abc.crop.jpg" rel="nofollow">http://mysite.com/img/abc.crop.jpg</a> ?</p>