.htaccess 404 Image

Discussion in 'HTML & Website Design' started by Pudge1, Aug 17, 2009.

  1. #1
    I want to make it so when you type in an invalid URL you go to a 404 page which I have accomplished. However I also want to make it so if a site requests an image from my domain that does not exist it gives them a 404 Image instead of a Image Error.
     
    Pudge1, Aug 17, 2009 IP
  2. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    I've tried doing a 404 to an image but then it does that for when there is a 404 error on the pages.
     
    Pudge1, Aug 17, 2009 IP
  3. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Prolly you'll have to redirect. like

    IF the request ends up 404 Not Found
    AND the request ends with .jpg .gif .png etc
    THEN redirect to your custom image at url whatever

    So it would be similar to your 404 statement except you'd look at what the request ended with too, and then add the redirect.
     
    Stomme poes, Aug 18, 2009 IP
  4. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #4
    Well I don't know how to do that. Is there any good .htaccess guides out there?
     
    Pudge1, Aug 18, 2009 IP
  5. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #5
    There are likely some more-English versions if you google "for dummies" with mod_rewrite (how I got my start) but ultimately the best is Apache's own pages... hm though I am assuming you're using Apache? If it's IIS I haz no clue. If you're using Lighty (lighttpd) then use this one.

    If you need to work on your regular expressions (how to say things like "if the file requested ends in .jpg, .gif, .png") I liked this page (though I just got the Mastering Regular Expressions by Jeffrey Friedl since they're good to know in many places).
     
    Stomme poes, Aug 18, 2009 IP
  6. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #6
    I can't find what I need in either of those guides. I also can't find any problems similar to this on the internet. Can someone tell me exactly what to write in there?
     
    Pudge1, Aug 18, 2009 IP