httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yehuda Katz <yeh...@ymkatz.net>
Subject Re: [users@httpd] Show Alternate Image if Requested Image is Missing
Date Tue, 03 May 2016 15:02:56 GMT
On Tue, May 3, 2016 at 10:52 AM, Julie Kurpa <jkurpa@volusia.org> 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

Mime
View raw message