开发者

404 Image Placeholder

I've got a product gallery I'm working on and just did an开发者_如何学JAVA import. This added a bunch of references to images that don't exist on the server.

Right now when the image tries to load, it's got that broken image icon, which is ugly, and well, should be handled better.

Ideally, whenever a broken image would be displayed -- that is to say when an image's path just doesn't exist -- I would like Apache to show a placeholder image instead.

Is there any way to do this via .htaccess?


Use RewriteCond with -f to check if the file exists, e.g.:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*(\.gif|\.jpe?g|\.png)$ placeholder.jpg [L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜