找不到檔案時重定向到預設圖像

找不到檔案時重定向到預設圖像

我從 iOS 應用程式將 Apple Game Center 用戶的小頭像上傳到 Web 伺服器的/ios-avatars/目錄中。

但有些球員沒有任何照片。

透過使用 Apache mod_rewrite 是否可以將「未找到」請求重新導向到類似/ios-avatars/GC123456789.png的檔案/images/default.png

答案1

您甚至不需要為此重寫。只需使用一個ErrorDocument...

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

相關內容