-1
How do I block other domains from uploading my images?
-1
How do I block other domains from uploading my images?
0
A strategy for what you want, would create an intermediary page to load your images, with this you can detect the origin of the request, below I will put an example in PHP.
<?php
if(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'http://www.seusite.com.br') === 0 && isset($_GET['img'])){
$name = './imagens/' . $_GET['img'];
$fp = fopen($name, 'rb');
header("Content-Type: " . mime_content_type($name));
header("Content-Length: " . filesize($name));
fpassthru($fp);
exit;
}
?>
Example of a page using the image:
<img src="imagens.php?img=icone.jpg" />
To be more effect you have to block apache direct access to image folder and its files.
Browser other questions tagged nginx
You are not signed in. Login or sign up in order to post.
What you’re looking for is a way to ban
Hotlinking
, look forHTTP_REFERER
, there are some techniques to avoid this.– Homer Simpson