Lol5916 Posted February 11, 2009 Share Posted February 11, 2009 I know this uses .htaccess. How do I make it so that if someone accesses one of my files, that it will be executed as a php script. For example, let's say we use .jpg. Someone goes to http://site.com/image.jpg, I want it to run image.php so that code can be run(visitor information) and then an image will be displayed. Quote Link to comment https://forums.phpfreaks.com/topic/144728-solved-how-do-i-do-this/ Share on other sites More sharing options...
Lol5916 Posted February 11, 2009 Author Share Posted February 11, 2009 Ok, I read a bit about this and I think this might work, can anyone confirm or deny? AddType application/x-httpd-php jpg Quote Link to comment https://forums.phpfreaks.com/topic/144728-solved-how-do-i-do-this/#findComment-759444 Share on other sites More sharing options...
corbin Posted February 11, 2009 Share Posted February 11, 2009 That will work, but that will mean your file will actually be named image.jpg. In other words, image.jgp would contain PHP code. If you wanted to use a file named image.php, but have image.jpg use it, you could either use an Alias command, or mod_rewrite. (An Alias command would be more efficient.) RewriteEngine On RewriteRule ^/path/to/image.jpg /path/to/image.php Quote Link to comment https://forums.phpfreaks.com/topic/144728-solved-how-do-i-do-this/#findComment-759448 Share on other sites More sharing options...
Lol5916 Posted February 11, 2009 Author Share Posted February 11, 2009 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/144728-solved-how-do-i-do-this/#findComment-759450 Share on other sites More sharing options...
corbin Posted February 11, 2009 Share Posted February 11, 2009 No problem ;p. Quote Link to comment https://forums.phpfreaks.com/topic/144728-solved-how-do-i-do-this/#findComment-759455 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.