cancel
Showing results for 
Search instead for 
Did you mean: 

Image redirect

Peter_Vaughan
Grafter
Posts: 14,469
Registered: ‎30-07-2007

Re: Image redirect

Quote from: ianscales
I might be barking up the wrong tree here but, if your not already using a customised 404 page could you not use that to display the 'image not available' message.
I know the above would be a bit messy but at least it should fix it for now.

The 404 error is for html pages that are not found, it won't work for individual images on a page that does exist.
MikeWhitehead
Grafter
Posts: 748
Registered: ‎19-08-2007

Re: Image redirect

Would this page be of any assistance to you?
http://www.garnetchaney.com/htaccess_tips_and_tricks.shtml
ianscales
Grafter
Posts: 75
Registered: ‎30-07-2007

Re: Image redirect

Not wishing to appear stupid (Quite easy in my case) why is he getting a '404' page when it's the image that can't be found?
Ian
MikeWhitehead
Grafter
Posts: 748
Registered: ‎19-08-2007

Re: Image redirect

Quote from: ianscales
Not wishing to appear stupid (Quite easy in my case) why is he getting a '404' page when it's the image that can't be found?
Ian

He isn't. What he is looking for is a way to redirect specific image requests to a generic "Image not found" image, so that broken image links aren't shown on forums that he used to post on.
ianscales
Grafter
Posts: 75
Registered: ‎30-07-2007

Re: Image redirect

I understand what he's trying to do, but he said............
« Reply #13 on 29/08/2007, 17:19 »   
--------------------------------------------------------------------------------
@oliverb
I appreciate you trying to help. I just tried that with and then with but I still just get a 404 error. Still open to any suggestions.
ratbag
Grafter
Posts: 369
Registered: ‎01-08-2007

Re: Image redirect

Quote
The 404 error is for html pages that are not found, it won't work for individual images on a page that does exist.

Hmmm...
If I go to http://www.me.plus.com/1.jpg
I do get a 404 error page. Is that not normal?
@MikeWhitehead
I'll take a look at that link but everything I've found so far on the web either doesn't mention what I'm trying to do, or gives the same answers as I've had here which -- for whatever reason -- doesn't work for me.
Thanks for trying to help everyone.
ratbag
Grafter
Posts: 369
Registered: ‎01-08-2007

Re: Image redirect

Well, thank you MikeWhitehead. That link you supplied seems to have the solution.
If I replace
#RewriteCond %{REQUEST_URI} !-U

with
RewriteCond %{REQUEST_FILENAME} !-f

it works. Well I haven't tried it extensively yet but it does show a default image if the requested one doesn't exist, and it does show the proper image if it does.
Now, is there anything wrong with using this? I don't like using code when I don't understand it really. What does the -f switch do?
Thanks for any help.
Peter_Vaughan
Grafter
Posts: 14,469
Registered: ‎30-07-2007

Re: Image redirect

The -f switch is just a test for the existence of the file you have specified in the previous parameter of the rewrite condition.
So it basically means if the file exists, do the corresponding  rewrite rule
In your case its using the reverse by specifying ! (not) so it is saying if the file does not exist do the rewrite rule.
The same goes for the previous text using -U which means if the specified URI exists, do the rewrite rule or !-U is if the URI does not exist do the rewrite rule.
See http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
For the meaning of -f etc see http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond
ratbag
Grafter
Posts: 369
Registered: ‎01-08-2007

Re: Image redirect

Thanks Peter. So ! = not same as in C (C++).
MikeWhitehead
Grafter
Posts: 748
Registered: ‎19-08-2007

Re: Image redirect

Quote from: ratbag
Well, thank you MikeWhitehead. That link you supplied seems to have the solution.

I'm glad this resolved your problem Smiley