Re: Show Alternate Image if Requested Image is Missing

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

 



BTW, Here is a snippet from the rewrite log:

172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba7ce8/initial] (2) init rewrite engine with requested uri /images/sRegion.png
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba7ce8/initial] (3) applying pattern '\\.(gif|jpe?g|png|bmp)$' to uri '/images/sRegion.png'
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba7ce8/initial] (4) RewriteCond: input='/images/sRegion.png' pattern='!-f' => matched
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba7ce8/initial] (2) rewrite '/images/sRegion.png' -> '/images/sketches/no_sketch.jpg'
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba7ce8/initial] (2) local path result: /images/sketches/no_sketch.jpg
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba7ce8/initial] (2) prefixed with document_root to /mnt/data/pawebdata/docs/images/sketches/no_sketch.jpg
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba7ce8/initial] (1) go-ahead with /mnt/data/pawebdata/docs/images/sketches/no_sketch.jpg [OK]
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba3d10/initial/redir#1] (2) init rewrite engine with requested uri /404.html
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba3d10/initial/redir#1] (3) applying pattern '\\.(gif|jpe?g|png|bmp)$' to uri '/404.html'
172.30.29.19 - - [03/May/2016:11:07:56 --0400] [pawebdev1.vcgov.org/sid#7f47d6a93b60][rid#7f47d6ba3d10/initial/redir#1] (1) pass through /404.html

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

>>> "Julie Kurpa" <jkurpa@xxxxxxxxxxx> 5/3/2016 11:16 AM >>>
Thanks Yehuda,

I tried your suggested code already and have just retried it.   The behavior is that all jpg's are now not showing at all.    

>From what I tell from the rewrite.log, it is pasting the DocumentRoot path in front of the path to the "no_sketch.jpg" for all JPG references.  

The DocumentRoot is "/mnt/data/pawebdata/docs"

Here's what the log shows is being used for the path to "no_sketch.jpg"

/mnt/data/pawebdata/docs/images/sketches/no_sketch.jpg

Note that I did not configure this Apache environment.  I'm coming in (inexperienced...but not dumb) with the assignment to show "no_sketch.jpg" for missing JPGs in the /image/sketches path and having to work with someone else's configuration. 
So I'll try to give the best information I can. 


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

>>> Yehuda Katz <yehuda@xxxxxxxxxx> 5/3/2016 11:02 AM >>>
On Tue, May 3, 2016 at 10:52 AM, Julie Kurpa <jkurpa@xxxxxxxxxxx> wrote:

> The sketches themselves are JPGs located within a directory on the Linux
> server.
> 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 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>
>

You need to use RewriteRule, Redirect has nothing to do with RewriteCond.
Something like the following should be enough:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(gif|jpe?g|png|bmp)$ /images/sketches/no_sketch.jpg [NC,L]

I also usually recommend not using the <IfModule> directive. If you want
this to work, you probably want the server to show an error if the rewrite
module isn't loaded rather than ignore the configuration.

- Y


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


---------------------------------------------------------------------
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