Mod Rewrite for redirected image

Discussion in 'Apache' started by mykg4orce, Jun 28, 2010.

  1. #1
    Hello, first post.

    I am loading a bunch of images from a remote company server which contains product images. The images are loaded by a serial number. Problem is that not all products have images. So the remote server automatically substitutes a blank.gif whenever the serial number provided fails.

    The site i am building, I want to substitute my own "No Product Image Available" image whenever the blank.gif is requested.

    How can i do this on the server level?

    I have a PHP script that does this pretty well but it slows down the page load time.

    I am hoping if I can simply get an rewrite rule to replace blank.gif with "my-own-image.jpg".
     
    mykg4orce, Jun 28, 2010 IP
  2. bvsonline

    bvsonline Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this one.

    ==========
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$
    RewriteRule .* path/to/my-own-image.jpg[L]
    ==========
     
    bvsonline, Jun 29, 2010 IP
  3. esupportsnet

    esupportsnet Greenhorn

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    From which location this blank.gif is being requested?
     
    esupportsnet, Jun 29, 2010 IP
  4. mykg4orce

    mykg4orce Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    good question...

    the image is being loaded from something like this:

    http://www.remote.com/directory/blank.gif
     
    mykg4orce, Jun 29, 2010 IP
  5. mykg4orce

    mykg4orce Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    this is what happens:

    when I request image file:
    http://www.remote.com/directory/123456.jpeg (302 Found)

    the remote.com server realizes it's not available and sends back

    http://www.remote.com/directory/blank.gif (304 Not Modified)
     
    mykg4orce, Jun 29, 2010 IP
  6. mykg4orce

    mykg4orce Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This doesnt work, also I think this Condition is forcing all images to be substituted with one image.
     
    mykg4orce, Jun 29, 2010 IP
  7. mykg4orce

    mykg4orce Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    any ideas?
     
    mykg4orce, Jul 4, 2010 IP