1

I want to block users to our site that are coming from links on seriously inappropriate website (e.g. warez, link bait sites, etc).

I have tried this but doesn't work - I go to the blocked site, click there to our site, they still get our site:

Under Rules:

<rule name="Blacklist block" stopProcessing="true">
   <match url=".*" />
   <conditions>
     <add input="{HTTP_REFERER}" pattern="^(?:https?:\/\/)?(?:www\.)?([^\/]+)(.+)?$" />
   <add input="{DomainsBlackList:{C:1}}" pattern="^block$" />
  </conditions>
  <action type="AbortRequest" />
</rule>

Then under Rewrite:

<rewriteMaps>
   <rewriteMap name="DomainsBlackList" defaultValue="allow">
    <add key="badsite.com" value="block" />
 </rewriteMap>

I've seen this format used as examples all over Stack Exchange, Googling, etc., so not sure why it won't work.

Am I misunderstanding how to have the link basically go nowhere when clicked from the refering site (or show blocked)?

  • Have you confirmed that the browser is sending the HTTP Referer header as you expect? – MrWhite Mar 2 at 23:55
  • Not clear on your question - the rule matches pattern for https, which the example site site is. Is the rule wrong or is there wildcard for http vs https? – SKidd Mar 3 at 8:04
  • Re-read your comment and realize, are they using techniques to not send the HTTP referer header. Could be but there are over a dozen sites, some of which are not specifically "evil" just very undesirable that would not likely do that (just best-guess). The rules for these other sites don't do anything, either. I'll dig deeper on that. Meanwhile, is there anything in the code that doesn't look correct? As my question stated, the code is widely available so seems like it should be good code. – SKidd Mar 3 at 14:58

Your Answer

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

Browse other questions tagged or ask your own question.