acctman Posted March 6, 2008 Share Posted March 6, 2008 I'd like to rewrite the way images are shown on my site, with a php script so if image http://domain.com/2005/02/39/39-3001.jpg is loading the url would show http://domain1.com/display.php?3001 and display.php would not allow direct access from other domains the referring URL would have to be coming from domain1.com or domain2.com. The html img src code has to be able to read "http://domain1.com/display.php?3001" and display an image thanks Quote Link to comment Share on other sites More sharing options...
deadonarrival Posted March 7, 2008 Share Posted March 7, 2008 You want to use .htaccess and url re-writing. I'm no expert, so google it or I'm sure someone will help out soon enough. Edit: found it RewriteEngine on rewriterule (.*)\.jpg$ /display.php?a=$1.jpg [R,L] Should work I think. Then in display.php just make sure the referrer is allowed (in_array() should do the job nicely) and display the image. Quote Link to comment Share on other sites More sharing options...
corbin Posted March 7, 2008 Share Posted March 7, 2008 The following is if you want to go down the PHP path: How is it supposed to map 3001 to 2005/02/39/39-3001.jpg with just "?3001"? It would have to know where the image was, but if the script knew that, it could just do something like: [psuedo code] if(referer == from this site) { //get image id from the ?number (process $_SERVER['QUERY_STRING']) if(image_exists) { readfile(path_to_image); exit; } } Quote Link to comment Share on other sites More sharing options...
deadonarrival Posted March 7, 2008 Share Posted March 7, 2008 Good point, I was assuming that all the images were in one folder (just trying to do what's requested in the first post) Quote Link to comment Share on other sites More sharing options...
acctman Posted March 7, 2008 Author Share Posted March 7, 2008 the url structure that i added is based on the user sign date. domain1.com/2005/02/39/39-3001.jpg year/mon/userid/userid-sqlauto#.jpg domain1.com = img/video domain and server what would you suggest with this setup? Quote Link to comment 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.