I'd like to use mod_rewrite to handle my requests of avatar images.
I've got a folder containing all .png
images and the file is named after the account's username.
So I would like requests for /avatar/Juddling
, to show the image, /images/avatars/Juddling.png
BUT if that file doesn't exist, I would like it to show a default.png
image.
Options +FollowSymLinks
Options +Indexes
Options -MultiViews
RewriteEngine On
RewriteRule ^avatar/(.*)$ images/avatars/$1.png [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^avatar/(.*)$ images/avatars/default.png [NC,L]
Apache only seems to be handling the first RewriteRule
, as I'm getting a 404 if the avatar isn't there rather than seeing the default image.