Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have the image in the URL (my server):

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.

How to do it?

share|improve this question

migrated from Oct 24 '11 at 18:52

This question came from our site for professional and enthusiast programmers.

1 Answer 1

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.