i know this has probably been answered before but i really don't know how to word this.
basically, i'm trying to store images, but when retrieving them i'd like the url to look something like http://www.example.com/xdfg485324
I know mvc .net does this with routes and controls and stuff, but is there a way to do that with php?
i was thinking that maybe since that xdfg485324 directory was not found, i would have a php script run and check to see if that image exists in the database then return the actual image data only (i'm not storing the actual image data in the database though, although i could)
As far as i know there's not really actually a good reason to do this, i just thought it looked more professional.
EDIT:
Thanks to Rasclatt getting me on the right track and providing some htaccess code, i was able to do exactly what i wanted, and the solution was something like this:
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^image/(.*)$ /test/image/?image=$1 [NC,QSA,L]
my actual url looks something like this "http://localhost/test/image/235443" i have an index.php in the image directory which gets called after this url rewrite.
images/index.php
<?php
if(isset($_GET['image']))
{
$filename = "../uploadedimages/".$_GET['image'].".jpg";
if(file_exists($filename))
{
header('Content-Type: image/jpeg');
$image = imagecreatefromjpeg($filename);
imagejpeg($image);
imagedestroy($image);
}
}
?>
all uploaded files are saved as jpg into the /test/uploadedimages directory, so after this script is ran, it returns the image requested from the uploadedimages directory, but the url still stays the same, even if you get the url to the image.