This is what I need to achieve:
Request: http://www.example.com/image5.jpg
Should rewrite, for example:
RewriteRule ([^.]+)\.jpg$ /image.php?image=$1
Now, in my image.php
, how do I serve the image, if I know where it is?
For example:
<?php
$path = '/images/5/2/3/1/small/latest/'.$_GET['image'].'.jpg';
?>
What is the best way to handle this request, so that it behaves like a image file (sends an image header) and displays the image?
There are various alternatives around the net, mainly X-Sendfile
and readfile()
, but I'm not sure what is the optimal solution and why.