| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Force .PNG image to be run as PHP; Or stop .png from being cached? | |
|---|---|
| Tweet Topic Started: Feb 4 2007, 02:29 PM (2,895 Views) | |
| IceMetalPunk | Feb 4 2007, 02:29 PM Post #1 |
|
We are all IMPerfect. Be proud!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
OK, here's my issue: I'm using PHP mixed with a Winamp plugin to create dynamic signature images that show the song/artist I'm currently listening to. Being a dynamic image, I'd like it not to be cached. I can do that with headers in a PHP file, but as you all know, forums don't allow PHP images, meaning I need to output the image as a separate .PNG file. Now I run into the problem: If it's a .png file, how can I stop it from being cached? So here's my question in a nutshell: Is there a way to either stop .PNG images in a forum signature not to be cached, or force PNG images to run as PHP so I can send the no-cache header with it? -IMP
|
![]() |
|
| Jory | Feb 4 2007, 02:41 PM Post #2 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
If your host runs Apache and has mod rewrite running, simply make a file called .htaccess with the following in it:
or if its just one image:
(Just put the file in the directory the images are in.) |
![]() |
|
| IceMetalPunk | Feb 4 2007, 02:58 PM Post #3 |
|
We are all IMPerfect. Be proud!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I'm not sure if my host is running Apache or not, but I'll try it. -IMP ![]() *EDIT* When I put that .htaccess file (the 1-file replacement version) inthe folder on my FTP account, all my files give this page instead of the real file:
|
![]() |
|
| Jory | Feb 4 2007, 03:55 PM Post #4 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Hmm.. *wonders what he did wrong* :S
Try that. |
![]() |
|
| IceMetalPunk | Feb 4 2007, 05:36 PM Post #5 |
|
We are all IMPerfect. Be proud!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Now I don't get an error, but it still doesn't work. I have this in the .htaccess file:
AMPSIG.php definately exists in the same folder. I went to MYSERVER/winampsigimage.png and got the 404 Not Found error saying "winampsigimage.png was not found". -IMP
|
![]() |
|
| Ben | Feb 4 2007, 07:11 PM Post #6 |
|
Quantum-locked when observed.
![]()
|
Upload a phpinfo() page and check if mod_rewrite is present. If it isn't, that'd be the problem. |
![]() |
|
| IceMetalPunk | Feb 4 2007, 08:11 PM Post #7 |
|
We are all IMPerfect. Be proud!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Well, at least we found the problem now . Mod_rewrite is not one of the loaded modules. Is there any way to do this without using the mod_rewrite? I don't necessarily need it to redirect to a PHP page if I can get it to not cache the image file itself. Is there no way to accomplish this?-IMP
|
![]() |
|
| Jory | Feb 5 2007, 02:10 PM Post #8 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
You could try using something like . That way, software will think your using a PNG file, but the server will serve the PHP file. You can also just add something to the .htaccess file along the lines of
It tells the server to tell the browser that PNG images expire in 0 (zero) seconds. (Don't ask me what the A before the 0 is for though. :P) (Check if you have the expires module running the way Ben explained.) |
![]() |
|
| IceMetalPunk | Feb 5 2007, 08:50 PM Post #9 |
|
We are all IMPerfect. Be proud!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
How would I get a URL like "http://whatever/AMPSIG.php/winampsigimage.png" to point to the PHP file instead of the non-existant PNG. -IMP
|
![]() |
|
| Spikeman | Feb 6 2007, 03:16 AM Post #10 |
|
Member
![]() ![]() ![]() ![]() ![]()
|
Only with mod_rewrite. |
![]() |
|
| Jory | Feb 6 2007, 03:21 AM Post #11 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
No, not true. You don't need to do anything do make that work. Your webserver will try to go to /AMPSIG.php/winampsigimage.png, findout its not there, try to go to /AMPSIG.php, find its actually a file, and just serve that. (Note: I'm only 100% sure Apache works like this, but confident other systems do, too.) |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
3:00 PM Jul 11
|



![]](http://b1.ifrm.com/0/1/0/p601690/pipright.png)




. Mod_rewrite is not one of the loaded modules. Is there any way to do this without using the mod_rewrite? I don't necessarily need it to redirect to a PHP page if I can get it to not cache the image file itself. Is there no way to accomplish this?
3:00 PM Jul 11