I have the image in the URL (my server): http://www.example.com/example.jpg

If my user put this image URL on his site: return the image (normal).

If my user put this image URL on his browser: return redirect to my site, i.e. http://www.example.com/?fimage=example.jpg

How to do it?


Hello Caio Tarifa,

The following solutions works on my nginx dev server on Windows.

In nginx.conf, add the following to your main server instance.

location ~ \.jpg$ {
    root   html; // edit if you use a different path to your server root.
    index  index.html index.htm; // edit if you use other file types

If this solution doesn’t work for your configuration, take a look at the following sites:

NginX Http Rewrite Module

NginX.Conf - Full Example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy