When a website is particularly popular, it is possible that its contents, for example images, videos and so on in your site, are shown on another website beacuse most of people took those files and linked it to their site. Perhaps without any authorization and permission, you didn't realize about it. In the end, the result is the files will appear on sites that do not belong to us. Maybe this condition is annoying, it will enlarge your expense (bandwidth) of your site. But don't worry, you can have some return in terms of visibility or impressions of the ads especially images and videos that you have in your pages.

Fortunately, using URL Rewrite Module for IIS 7 or above is pretty straightforward to create a rule to handle this problem. All you have to do, once installed, you have to include this section in the web.config:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true" />
  <rewrite>
    <rules>
      <rule name="Avoid remote linking" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
          <add input="{REQUEST_FILENAME}" matchType="IsFile" />
          <add input="{REQUEST_FILENAME}" pattern="\.(png|jpg)" />
          <add input="{REQUEST_FILENAME}" pattern="blocked\.png" negate="true" />
          <add input="{HTTP_REFERER}" pattern="^http://www\.testredirect\.com/.*$" negate="true" />
        </conditions>
        <action type="Rewrite" url="/blocked.png" appendQueryString="false" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

As you can see, You can apply the node condition to all requests for files whose extensions are png or jpg (of course you can customize this setting at will). The last condition, in particular, allows you to see through the value of the variable HTTP_REFERER server, if the request was originated by a page that belongs to us or not. If not, the action is designated to perform a rewrite the URL to be processed, by sending the contents of a special image that you have provided (in your case, blocked.png) in a place that originally requested.

HostForLIFE.eu IIS 8.0 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.