Show Alternate Image if Requested Image is Missing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to modify an Apache configuration in Suse Linux.   The website is used to view Property  and a mixture of html and cgi scripts. 

The cgi scripts query an oracle database and supply information to the screen, one of which, is a sketch of the property.

The sketches themselves are JPGs located within a directory on the Linux server.

Some properties may be missing their JPG sketch and a 404 gets logged in the apache error_log.   

If the JPG for a property is found to be missing, I would like to show an alternate JPG called "no_sketch.jpg".

I've been trying various combinations of the Rewrite module that I've found in both Apache support forums and others.   

So far, the closest I've gotten it to work is for the "no_sketch.jpg" to show for every image, rather than just the one missing. 

A summary of the configuration is as follows:

An httpd.conf file that references a vhosts.d directory that contains two config files depending on the method of using either non-ssl or ssl.

I'm testing with the non-ssl approach and so only working with the vhosts.d/non-ssl.conf file.  

When the JPG is not found, it displays the following in the error_log:

[Tue May 03 09:38:23 2016] [error] [client 172.30.29.19] File does not exist: /mnt/data/pawebdata/images/sketches/82989.jpg, referer: http://pawebdev1.vcgov.org/cgi-bin/search.cgi 

I've added a section in the vhosts.d/non-ssl.conf file to handle the redirection but no joy so far.  It either doesn't work at all or it replaces all jpg files with the "no_sketch.jpg" file.  
I've tried a gazillion variations of the RewriteRule and am now trying the Redirect.  

I'm completely at a loss.    Here is what I have in my vhosts.d/non-ssl.conf file for this step:

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteLog /var/log/apache2/rewrite.log
 RewriteLogLevel 4
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_URI} "\.(gif|jpg|jpeg|png)$"
 Redirect  .* http://pawebdev1.vcgov.org/images/sketches/no_sketch.jpg 
</IfModule>


Here is a snippet from the rewrite.log that deals with the particular missing jpg called "82989.jpg".  

172.30.29.19 - - [03/May/2016:10:03:15 --0400] [pawebdev1.vcgov.org/sid#7fa11b67ab60][rid#7fa11b78ccc8/initial] (2) init rewrite engine with requested uri /cgi-bin/search.cgi
172.30.29.19 - - [03/May/2016:10:03:15 --0400] [pawebdev1.vcgov.org/sid#7fa11b67ab60][rid#7fa11b78ccc8/initial] (1) pass through /cgi-bin/search.cgi
172.30.29.19 - - [03/May/2016:10:03:15 --0400] [pawebdev1.vcgov.org/sid#7fa11b67ab60][rid#7fa11b788ca8/initial] (2) init rewrite engine with requested uri /images/sketches/82989.jpg
172.30.29.19 - - [03/May/2016:10:03:15 --0400] [pawebdev1.vcgov.org/sid#7fa11b67ab60][rid#7fa11b788ca8/initial] (1) pass through /images/sketches/82989.jpg
172.30.29.19 - - [03/May/2016:10:03:15 --0400] [pawebdev1.vcgov.org/sid#7fa11b67ab60][rid#7fa11b78dd98/initial/redir#1] (2) init rewrite engine with requested uri /404.html
172.30.29.19 - - [03/May/2016:10:03:15 --0400] [pawebdev1.vcgov.org/sid#7fa11b67ab60][rid#7fa11b78dd98/initial/redir#1] (1) pass through /404.html
172.30.29.19 - - [03/May/2016:10:03:18 --0400] [pawebdev1.vcgov.org/sid#7fa11b67ab60][rid#7fa11b788ca8/initial] (2) init rewrite engine with requested uri /cgi-bin/search.cgi



Julie Kurpa
Sr. Systems Programmer
  119 W. Indiana Ave
  DeLand, FL  32720
  Office:  (386) 736-5960 x12875


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx





[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux