Forum Moderators: phranque

Message Too Old, No Replies

.htaccess and default images

         

yabadabastum

4:04 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



previously my php cart called whatever button image they wanted, and all these button images are located in the same directory. There are quite a few different ones, but now i want to dynamically create each button. So my original thought was to place the appropriate php files (with the same name as the said button) in the directory, replacing the 'real' images.

I do not want to do this because there would be many files, and each file would contain similar code to the others - so is there any way that when a file is called in a certain directory, if that file doesn't exist, a default file in the directory is called?

Thanks. (maybe more of an apache question, i duon't really know)

yabadabastum

4:06 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



also, this default has to know what file was being called in the directory aswell,
thanks

jdMorgan

9:19 pm on Feb 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yabadabastum,

Welcome to WebmasterWorld!

Yes, use mod_rewrite [httpd.apache.org], and use RewriteCond %{REQUEST_FILENAME} -f ahead of RewriteRule to conditionally rewrite non-existent image requests to your image-generator file.

Jim