Forum Moderators: phranque
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
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
> 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
> 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
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]
Try one of these tweaked versions.
Internal rewrite (recommended):
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !-U
RewriteRule \.gif$ /rolleyes.gif [L]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !-U
RewriteRule \.gif$ http://yourdomain.co.uk/rolleyes.gif [R=301,L]
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 :-)