Forum Moderators: phranque

Message Too Old, No Replies

Serve alternative to missing image

Serve alternative to missing image

         

rfontaine

2:12 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



Hi,

If a webpage calls an image and that image does not exist is it possible to serve up a default image in its place on that webpage?

For example, if xyz.jpg does not exist then display missing-image.jpg.

I am running PHP on Apache 1.3x

Thank you in advance!

Ron

rfontaine

2:57 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



any ideas?

jdMorgan

3:09 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



rfontaine,

Using mod_rewrite's RewriteCond directive and "-f" flag, you simply make the rewrite conditional upon the requested file not existing.


RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.gif$ /replacement.gif [L]

Refs:
Apache mod_rewrite documentation [httpd.apache.org]
Apache URL Rewriting Guide [httpd.apache.org]
Regular Expressions Tutorial [etext.lib.virginia.edu]

Jim

rfontaine

6:17 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



Thank you very much Jim!