Forum Moderators: phranque
I have a lot of static HTML pages that link to images that no longer exist. Is it possible to load a "image not available" picture whenever the image is not on the server?
"...not on the server?" Your server, or theirs?
First thing that comes to my mind is: Would it not be better to simply treat it like one would link rot and just remove the dead link?
While I may not be clear on what you mean by 'static' pages, it is possible to make up just a simple "The image you requested is no longer available thru this website." file should do. Even at that, the extra work seems redundant.
Pendanticist.
If it was my site, I'd fix or remove the bad links. Second choice would be to redirect the requests for unavailable images to a single replacement image. Last choice is a 404. IMHO, a 404 usually means a webmaster (referring or referred-to) needs to do something to fix a problem.
Jim
If it was my site, I'd fix or remove the bad links. Second choice would be to redirect the requests for unavailable images to a single replacement image. Last choice is a 404.
That's pretty much what I suggested. Why fuss with something that surely falls under the 'routine maintenance' topic, unless there's something I'm unaware of when the distinctions being held to 'static'.
IMHO, a 404 usually means a webmaster (referring or referred-to) needs to do something to fix a problem.
<thwack!> :)
Correctamundo! Such a simple thing to create a custom 404 page and you can be as creative as you like too.
Too bad there are so many webmasters who pay inordinate attention to the front end of a website, while letting the really important stuff slide.
<Btw - Jim: I made it :)>
Pendanticist.
Got code?
Disclosure: I was a participant in an undeclared and informal "competition" to see who could come up with a clever rewrite to solve a posted problem the fastest. But after awhile, we were starting to post the same stuff to solve the same problems over and over again. Our wise and tolerant forum host [webmasterworld.com] asked us to "help those who help themselves", and "teach a man to fish so that he might eat for a lifetime", rather than "give a man a fish so that he might eat for a day", and that's what we've been trying to do.
A site search on WebmasterWorld for "mod_rewrite", "redirect", and ".htaccess" will turn up literally hundreds of similar posts. So, the goal is to help debug specific problems in snippets posted by members who've obviously done their homework, but who have hit an impasse - and thus to reduce repetitive postings.
Toward that end, there is also this fine new tutorial, Introduction to mod_rewrite [webmasterworld.com], which contains links to the Apache documentation, a regular-expressions tutorial, and other resources...
HTH,
Jim
I checked the forum for mod_rewrite image and mod_rewrite image redirect. All the discussion on redirects with images deal with hotlinking. What I want to do is to redirect (302) to a default image when the actual image is not found.
I'll keep looking [webmasterworld.com].
Derived from the Redirect Failing URLs To Other Webserver example in the Apache 1.3 URL Rewriting Guide [httpd.apache.org]...
in .htaccess:
Options +FollowSymLinks
RewriteEngine on
# Redirect missing catalog images to a default image. Let other missing resource requests 404 normally.
RewriteCond %{REQUEST_URI} !-U # if requested resource doesn't exist
RewriteRule ^catalog_image_path/.*\.gif$ /default_image_path/default.gif [L] # redirect to default image
The cited Rewriting Guide is directly linked from the tutorial linked in msg #10 above. The warning about subrequest inefficiency applies but in this case, due to the way mod_rewrite only evaluates RewriteConds if the pattern of a RewriteRule is matched (Yes! - See mod_rewrite Ruleset Processing), the check-for-file-exists subrequest is invoked only for gif images in the catalog section. Make the catalog_image_path in the RewriteRule as specific as possible, and I suggest storing only product images (not common page graphics and spacer gifs, etc.!) in that path location, if possible. The redirect is "silent"; That is, the browser thinks that it is getting the requested gif, and is not told otherwise. If you really want to send a 302 response, then change the RewriteRule flag from [L] to [R=302,L].
HTH,
Jim
Post Code [webmasterworld.com]
Posting code II [webmasterworld.com]
[edit]grammar error[/edit]
[edited by: sun818 at 5:38 pm (utc) on Dec. 31, 2002]
Then in the Perl file, load in logo.jpg (or whatever the parameter is) and send this file using Content-type: image/jpg header and then the file... or send an image missing file (that will always exist).
Disadvantages? Non - unless you want Google/FAST image search, I am not sure if these will index - I think Google will but FAST may struggle.