Block referrals from server IP address

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 4
Joined: 20 Aug 2012, 22:36

Block referrals from server IP address

20 Aug 2012, 22:44

I'm looking for help to create a rule to block referrals to my website from a specific IP address. I am able to create a rule to block redirects from a specific domain hostname but now I need to block a fixed IP address. We have a nasty domain name redirecting to our site and I was able to block the referrals from that hostname. Now they are redirecting that domain to a fixed IP which then redirects back to our site.

my conditions for the hostname was
Code: Select all
RewriteCond %{HTTP_REFERER}domain\.com[NC]


this doesn't work for a referring server ip address which is sending 302 redirects.

Any help appreciated!

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Block referrals from server IP address

21 Aug 2012, 07:51

Hello, Philip

Here's what should be used:

RewriteCond %{REMOTE_ADDR} ^203\.20\.65\.29$
RewriteRule .? - [F]

User avatar
Posts: 4
Joined: 20 Aug 2012, 22:36

Re: Block referrals from server IP address

21 Aug 2012, 12:47

Hi Anton

Thanks for the reply but that solution will block requests from that IP as the remote address. I need to block traffic being referred from that IP address. For example my host machine visits that IP address and is redirected to my web server. The requests will come from my host machine but referred from that IP.

Any help would be appreciated if this is possible at all,

Thanks again,
Philip

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Block referrals from server IP address

22 Aug 2012, 07:59

Hello, Philip

The thing is that browser doesn't deliver this information. The only field is Referer and it sometimes contains host. You could try to resolve the IP address using the hostname on your server, but ISAPI_Rewrite can't do that and it may be rather slow.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 12 guests