I have a PHP file: index.php at the root of my web directory (something along the lines of):
<?php
echo '<div>
<img src="images/test.png">
</div>';
?>
And I have a .htaccess file in the 'images/' directory which contains the following:
deny from all
As I understand it, this should allow <img src="images/test.png">
to be displayed on the webpage but should not allow a user to access the test.png
file directly as follows: www.example.com/images/test.png
(I expect this to throw a forbidden error or something along these lines).
Unfortunately, the above leads to the image not displaying on index.php
as well as the image not displaying via direct url: www.example.com/images/test.png
. If I remove the .htaccess file, the image displays fine, but it can be accessed by direct URL.
Any ideas why this would not be working as expected?