How can I redirect image 404 error on Amazon S3 to my own server How can I redirect image 404 error on Amazon S3 to my own server codeigniter codeigniter

How can I redirect image 404 error on Amazon S3 to my own server


This is my workaround to identifying the 404 error.

  1. Enable S3 web service
  2. Configure the Error Document to a file-not-found.jpg
  3. $result = $s3->getObject(array( 'Bucket' => 'my bucket', 'Key' => 'path/to/file' ));
  4. Use md5 or crc32 to identify if the returned object is file-not-found.jpg
  5. Redirect to your own server


If you're using codeigniter, have a look at the reserved routes http://codeigniter.com/user_guide/general/routing.html. you can specify a specific controller for any 404 error.