Replacing missing images with a default or placeholder... htaccess?

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
rhiaro
Forum Members
Forum Members
Posts: 13
Joined: Fri Jan 29, 2010 3:53 pm

Replacing missing images with a default or placeholder... htaccess?

Post by rhiaro »

Hey folks,

I have some images that are dynamically generated from variable names in a module.  Occasionally, one of them might not actually exist on the server yet, so I want a default image to appear in its place.

I've done some Googling and played about with htaccess, but can't make it work yet.  I added this:

 

Code: Select all

RewriteEngine on
  RewriteBase /cms/
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|gif|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*$ /uploads/images/icon_default.png [L]
to the .htaccess file in /docs/
But it doesn't appear to be working.
The path to the image is correct in relation to the CMSMS root (I tried it in relation to the htaccess file too, that didn't work either).  Do I need the/a htaccess file in a different place (such as the root)?

Any pointers?

Doing it with PHP seems like overkill...

I feel like there should be something built into CMSMS to achieve this; am I missing it?

Thanks!
ajprogramming
Forum Members
Forum Members
Posts: 24
Joined: Sat Jan 09, 2010 4:38 pm

Re: Replacing missing images with a default or placeholder... htaccess?

Post by ajprogramming »

To use the .htaccess file it needs to be in root.
rhiaro
Forum Members
Forum Members
Posts: 13
Joined: Fri Jan 29, 2010 3:53 pm

Re: Replacing missing images with a default or placeholder... htaccess?

Post by rhiaro »

My CMSMS files aren't in the actual server root, would that be a problem?
ajprogramming
Forum Members
Forum Members
Posts: 24
Joined: Sat Jan 09, 2010 4:38 pm

Re: Replacing missing images with a default or placeholder... htaccess?

Post by ajprogramming »

Sorry the root of your cms install. Should be the same as 

Code: Select all

RewriteBase /cms/
Post Reply

Return to “The Lounge”