I want to redirect users if they access the gif images directly.
http://www.example.com/uploads/file.gif
This should be redirected to home page or some other page.
Or
If the image is directly accessed, I want to show a html form or button to go to html form.
location ~* (\.gif)$ {
rewrite ^/* /imagedisplay/ last;
}
I tried to use redirect but it didn't help.
Please advice to prevent images to be hot linked.
Best Answer
Probably you ask how to prevent hotlinking? Nginx has built in functionality to do that: http://nginx.org/en/docs/http/ngx_http_referer_module.html
See an example below: