Aurora078 Posted October 6, 2010 Share Posted October 6, 2010 I'm using GD to re-create an image from a url. The only problem is instead of serving the image from blah.php?id=imgid, i want to serve it from md5'd id-picname.png . How can this be accomplished? Quote Link to comment Share on other sites More sharing options...
Zeggy Posted October 6, 2010 Share Posted October 6, 2010 Mod rewrite? Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted October 6, 2010 Share Posted October 6, 2010 So you don't want the filename in the argument but some... hash? well you can't directly you must store the full path in a db with as key an hash (md5 or whatever) and then you can use that to find the true path. Quote Link to comment Share on other sites More sharing options...
Aurora078 Posted October 6, 2010 Author Share Posted October 6, 2010 THe hash isnt really what im trying to say. Im just saying how would i get the image to come out at .png instead of .php ? so i could access it like image.png instead of images.php?image=theimage Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted October 6, 2010 Share Posted October 6, 2010 so either you use a mod rewrite for something like /myimg/img.png which would be then pointing at myphp.php?image=img.png or you could use a the PATH_INFO to have an url like myphp.php/img.png Is it what you are looking for? Quote Link to comment Share on other sites More sharing options...
Aurora078 Posted October 6, 2010 Author Share Posted October 6, 2010 this is mainly what i used.. RewriteEngine on RewriteRule ([0-9a-zA-Z])\.png$ /images/?id=$1 and of course the image is fetched by the id of user, and some other variables all mixed up for reasons. Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted October 6, 2010 Share Posted October 6, 2010 RewriteRule ([0-9a-zA-Z])\.png$ /images/?id=$1 Will rewrite ALL the .png files to that... are you sure that's what you want? Quote Link to comment Share on other sites More sharing options...
Aurora078 Posted October 6, 2010 Author Share Posted October 6, 2010 No, just specifics, but i'm fairly new to mod_rewrite so i dont know any other way. Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted October 6, 2010 Share Posted October 6, 2010 By doing so: RewriteEngine on RewriteRule ^/users/([0-9a-zA-Z])\.png$ /images/?id=$1 You say that only the urls with /users/XYZ.png will be converted what doesn't start with /users/ will not (it is just an example). I you just say whatever ends by .png will have way too many matches and could be counter productive. 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.