CMC Posted November 12, 2008 Share Posted November 12, 2008 Hi, I've made an image upload/view script that works nicely but now I'm trying to have the view script generate nice URL's. i.e: instead of view.php?id=some_id have something like /images/some_id.file_extension (/images/23.gif). The files are stored in a database. Does anyone know if this is possible? I've been looking around and doing a lot of reading but I haven't found anything suggesting if it's possible. I haven't tried either because I am unsure of how to approach the coding aspect. I have basic mod_rewrite knowlede but what is stumping me is how to pass the .gif part. The .gif part will not be used in retrieving the actual image, it's just there to make the URL look nice Also, everything is dynamic; so if the image was a PNG then it would be /images/24.png. Am I making sense? Quote Link to comment Share on other sites More sharing options...
foxtrotwhiskey Posted November 12, 2008 Share Posted November 12, 2008 Hey CMC, I know exactly what you're talking about and I know how you could do it. Try this for your rewrite rule: RewriteRule ^images/([0-9]+)\.(gif|jpg|png)$ view.php?id=$1 [L] Add any other file extensions as you need them. Let me know how it goes! Quote Link to comment Share on other sites More sharing options...
CMC Posted November 12, 2008 Author Share Posted November 12, 2008 Thank you very much! The answer is so much simpler than I thought it would be. Thanks foxtrowhiskey Quote Link to comment Share on other sites More sharing options...
sandiman Posted April 10, 2009 Share Posted April 10, 2009 I have a very similar question, only the url structure is different. I would like to request an image of a volcano for example, stored on the server as: img/imagenumber.extension ,via 2 different urls. www.mydomain.com/img/imagenumber/volcano.extension or www.mydomain.com/img/volcano.extension?img=imagenumber I can't get a mod write to function for either case, can someone help me? 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.