I am using Apache's mod_rewrite to route demands for .digital files to some directory outdoors my web root.

It generally continues to be fine, but you will find a couple of images that don't display. Then i recognized that after I personally use PHP's get_headers() function on my small image Web addresses, they all are coming back "Content-Type: text/html charset=UTF-8" rather than the correct image/jpeg header types.

I've attempted clearly setting the "Content-Type: image/jpeg" header but still, none of my images return the right headers - although most do display properly, but I am unsure why.

How do i assure a Digital file is distributed using the correct header when redirecting via mod_rewrite?

Thanks, John

You may also set the Content-Type header area with mod_rewrite using the T flag:

RewriteRule … … [T=image/jpeg]

This is exactly what you could do this. Produce a PHP file which get the best file and passes it through

<?php 
$sImage = 'imagename.jpg';
header("Content-Type: image/jpeg");
header("Content-Length: " .(string)(filesize($sImage)) );

echo file_get_contents($sImage);

or

<?php
$sImage = 'imagename.jpg';
$rFP = fopen($sImage, 'rb');

header("Content-Type: image/jpeg");
header("Content-Length: " .(string)(filesize($sImage)) );

fpassthru($rFP);
exit;

What about image which isn't.digital. Like .presen, ...

What about image which isn't.digital. Like .presen, ...

You will need to use mime_content_type() (that is deprecated) or even the fileinfo extension to find out which content-type to transmit.

Edit: I do not recommend this, but when you're using a specific subset of file extensions, you might produce a small dictionary variety of content-types and employ the file extension to find out which someone to send.