Hey guys, I've been reading on and on about how to fix broken image link. I can't figure out what I am doing wrong. Here's what I have: RewriteCond "%{REQUEST_URI}" !-f RewriteRule \.(gif|jpe?g|png|bmp) /images/nophoto.gif [NC,L] my default image is at http://www.mydomainname.com/store/images/nophoto.gif I want all broken images from any url from any product on my site to point to the one above. What am I missing? Any ideas?
%{REQUEST_URI} generally doesn't include the full path to the file. You'll need to prepend the path to the directory where the request URI would reside for the -f flag to work. Chances are the %{DOCUMENT_ROOT} environment variable with work for that purpose. RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f Code (markup): Now, I don't remember which browsers it was, or whether it was versions that people don't use anymore, but it used to be that rewriting the URI for an image to a different type of image, for instance the request is for a JPG and you want to return a default GIF, the browser will be expecting a JPG and will consider the GIF a broken file before just displaying a broken image icon. You'll want to at least make sure you use the [R] flag so that the browser has a chance to react to the image change. Ideally you'll rewrite each image type to the type requested, meaning you'll have multiple defaults in different formats. But, as I mentioned, things may have changed so you'll want to experiment with that for the browsers your audience uses.
Thanks for the tip. Most of my images are JPG so I rewrote the short script: RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteRule \.(jpg) /images/nophoto.jpg [NC,L] I'm mainly consigned about the "bastard browser from hell" IE. Any other tips to why wouldn't this work?
I'd say virtual-host. It is hosted by hostmonster. The root of my directory has an .htaccess file. I can provide screen shots if necessary. Thanks for your help by the way. I have posted this question on numerous forums but nobody seems to know. I wonder if this is very hard to do or something.
I don't think you're going to have access to RewriteLog at Hostmonster. I would start by trying this in the htaccess of the sites root directory. RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteRule \.(jpe?g|gif|png)$ http://www.mydomainname.com/store/images/nophoto.gif [L,R=301] Code (markup):