If I put the following in my web.config, this will stop people hot linking any images on my site? Clearly I'd edit the domains to reflect my addy. Thanks for any help.
I haven't personally tried the method you're attempting, but I'd recommend a slightly different approach, if you're open to it...
If you're using a WAF to protect your website, you should be able to easily enable this as a setting. In Cloudflare, you can do this with their free plan. (See below.) The other benefit is that you get another layer of protection and a CDN that both help your website perform better for all visitors. :)
Hello,
I agree with Will that the solution Cloudflare offers (free) works very good but if you really want to do it your self use this:
<code><rewrite> <rules> <rule enabled="true" name="Block Hotlinking" stopprocessing="true"> <match url="(?:jpg|jpeg|png|gif|bmp)$"> <conditions logicalgrouping="MatchAll" trackallcaptures="false"> <add input="{HTTP_REFERER}" pattern="^https?://(.+?)/.*$"> <add input="{DomainsAllowList:{C:1}}" pattern="^block$"> <add input="{REQUEST_FILENAME}" negate="true" pattern="no-hotlink.png"> <add input="{REQUEST_URI}" negate="true" pattern=".*(hotlink-ok).*"> </add></add></add></add></conditions> <action appendquerystring="false" redirecttype="Temporary" type="Redirect" url="https://yourdomain.com/images/no-hotlink.png"> </action></match></rule> </rules> <rewritemaps> <rewritemap defaultvalue="block" name="DomainsAllowList"> <add key="www.server-essentials.com" value="allow"> <add key="www.bing.com" value="allow"> <add key="www.google.com" value="allow"> <add key="www.google.ch" value="allow"> </add></add></add></add></rewritemap> </rewritemaps> </rewrite></code>
In addition to the above you can put rewriterules, outboundrules and rewritemaps in seperate files like:
These Forums are for the discussion of the open source CMS DNN platform and ecosystem.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.