Like the title says, I'm looking for a rewrite rule that lets me redirect the url of a broken image to a default image. I saw this somewhere, but it didn't work... RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{REQUEST_URI} (.*).(gif|jpg|jpeg)$ RewriteRule ^(.*) http://sc.msn.com/c/portal/logo/full/msft.gif Code (markup): Any and all help is appreciated
This one is working for me, just tested it: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} ^(.*)\.(png|gif|jpg|jpeg)$ RewriteRule ^(.*) http://your.domain/path/to/image.png [L] </IfModule> Code (markup): Perhaps you forgot to prepend the the dot with a backslash.
Hey - thanks. That works for images on the main domain (example: domain.com/image.jpg) but not for images in other directories (example: domain.com/folder/image.jpg or domain.com/folder/folder2/image.jpg etc). Is there anyway to that? Thanks again and thanks in advance.
there is a much easier method IF - and only IF you have all your pics in a subfolder of the domain - in folders without text files, then you can simply place IN the .htaccess OF THAT SUBfolder ( NOT domain / !!! ) another ErrorDocument 404 /path-to/replacement_pic.gif that is shorter than rewrite and does the same but for all - hence it only makes sense of NO text content files in that sub-folder structure. I have above working since long for wrong wallpaper requests
Anyone ever tried placing an ErrorDocument directive isside a <FilesMatch> container restricted to images ? <FilesMatch "\.gif$"> ErrorDocument 404 /path/to/image.gif </FilesMatch> Code (markup): I think a seprate container would be needed for each image type, I've had problems with redirecting to images of different types in the past with other applications.