Forum Moderators: phranque

Message Too Old, No Replies

replacing missing images

with a default image

         

icecracker

9:33 pm on Jul 20, 2003 (gmt 0)

10+ Year Member



Hello,
I host a lot of images that people use on forums and am moving servers, but instead of moving all the images too I thought I'd clear out and delete them all, but instead of just deleting them so they all show as red x's on forums I would like it to show an image telling people how to get the broken image re-instated.

So basically, somehow when someone loads a page somewhere on the internet that contains an image that was on my server, but is no-longer there, it displays a default image (using mod_rewrite in .htaccess?)

Suggestions / ideas please.

Thanks. :)

.ice

bcc1234

9:54 pm on Jul 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check the custom 404 tags placed inside the directory directive or inside filesmatch.

jdMorgan

9:56 pm on Jul 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



icecracker,

Welcome to WebmasterWorld [webmasterworld.com]!

A WebmasterWorld site search dug up this old thread, which contains one solution you might be able to use. See msg#12.

[webmasterworld.com...]

HTH,
Jim

icecracker

10:02 pm on Jul 20, 2003 (gmt 0)

10+ Year Member



jdMorgan, thanks for the welcome, I found that page via google, but it didn't work for me for some reason, any suggestions as to why?

jdMorgan

10:17 pm on Jul 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



icecracker,

> it didn't work

Well, did you get a server error, the replacement image didn't show up, or ...?

You might want to have a read of this Introduction to mod_rewrite [webmasterworld.com] thread, too, in order to get oriented.

I'll be happy to help with specific questions. :)

Jim

icecracker

10:34 pm on Jul 20, 2003 (gmt 0)

10+ Year Member



Just the replacment image dosen't show. :(

I guess I'll figure it out eventually, but it's pissing me off because it's preventing me shutting down my old server :(

jdMorgan

11:12 pm on Jul 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



icecracker,

> replacment image dosen't show.

One thing that often causes trouble like this is that you'll need to flush your browser cache and any other caches between you and the disk with the image.

This applies if you are still seeing the original image. If you are seeing something else - like a broken image placeholder - then the problem is likely in the Rewrite Rule pattern or substitution.

Tell us what you image do see - what works, and what doesn't work... As much info as possible... Any data from your raw server error log file? That will help you get good answers faster.

Jim

icecracker

11:25 pm on Jul 20, 2003 (gmt 0)

10+ Year Member



I'm seeing the broken image placeholder, and there is no unusual errors in the server logs.

Thanks for the help.

this is what I have in the .htaccess (the replacement image is just being used to test):

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{REQUEST_URI}!-U
RewriteRule ^/.*\.gif$ http://darkernet.co.uk/rolleyes.gif [L]

jdMorgan

11:49 pm on Jul 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



icecracker,

Try one of these tweaked versions.

Internal rewrite (recommended):


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !-U
RewriteRule \.gif$ /rolleyes.gif [L]

External redirect (if you require it for some reason):

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !-U
RewriteRule \.gif$ http://yourdomain.co.uk/rolleyes.gif [R=301,L]

HTH,
Jim

icecracker

10:01 am on Jul 21, 2003 (gmt 0)

10+ Year Member



both of those just give the broken image placeholder again :( (tried them on 2 different servers, to make sure)

icecracker

12:47 pm on Jul 27, 2003 (gmt 0)

10+ Year Member



Just to let you know, I have managed to get what I wanted working now.
I used the following code:

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}!-f
RewriteCond %{REQUEST_URI} (.*).(gif¦jpg¦jpeg¦png)$
RewriteRule ^(.*) http://darkernet.co.uk/missing.png

Not sure how efficient this is compaired to the code you posted, but it works for me :-)