Redirect to default image when file is not found

Alexander Farber asked:

From an iOS app I upload small avatars of Apple Game Center users to a web server, into an /ios-avatars/ dir.

But some players do not have any pictures.

By using Apache mod_rewrite is it please possible to redirect “not found” requests to files like /ios-avatars/GC123456789.png to /images/default.png?

My answer:


You don’t even need a rewrite for that. Just use an ErrorDocument

<Location /ios-avatars/>
    ErrorDocument 404 /images/default.png
</Location>

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.