How can I redirect image 404 error on Amazon S3 to my own server
This is my workaround to identifying the 404 error.
- Enable S3 web service
- Configure the Error Document to a
file-not-found.jpg
-
$result = $s3->getObject(array( 'Bucket' => 'my bucket', 'Key' => 'path/to/file' ));
- Use md5 or crc32 to identify if the returned object is
file-not-found.jpg
- 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.