Block Proxy Servers using .htaccess

Hello Friends !!

We all know about spamming.

In my last post we can block IP address using .HTACCESS. But suppose proxy server used for spamming then what will you do ? In using proxy server, every time IP address changed.

Generally hackers are also use proxy servers to hack the site.

Don’t worry about this. I found some code of .HTACCESS which blocks proxy servers to access your site.

How to Block Proxy Servers

This code help you to block proxy servers to access your site.

RewriteEngine on
RewriteCond %{HTTP:VIA} !^$ [OR]
RewriteCond %{HTTP:FORWARDED} !^$ [OR]
RewriteCond %{HTTP:USERAGENT_VIA} !^$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR} !^$ [OR]
RewriteCond %{HTTP:PROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
RewriteCond %{HTTP:HTTP_CLIENT_IP} !^$
RewriteRule ^(.*)$ – [F]

You have to simply copy this code into your site’s root htaccess file.

Upload to your server, and test it. If any problem then comment me.

Original article by Perishable Press: http://perishablepress.com/press/2008/04/20/how-to-block-proxy-servers-via-htaccess/

Thanks….

You can leave a response, or trackback from your own site.

View Comments to “Block Proxy Servers using .htaccess”

  1. Butters says:

    i’m not too sure how good that script is.
    I tried it against a few proxies, and all of them got through.

    Putting this script in your Htaccess also made it so i couldn’t publish through “frontpage”. (cuz of the http protocol…and i believe frontpage acts like a proxy so it can push the web to the server).

    Just a little something i noticed.

    Wish there was a surefire way to keep people using proxies OFF a website. (other than only allowing certain IP’s)

  2. Adam says:

    It doesn’t work.

  3. Peter Vander says:

    I’ve tested this and it’d worth a shot, not sure the previous poster had this up and running properly.

    great to keep the nasty proxy users off your site!

  4. NettiCat says:

    This is great to definitely block all comment spam!

    I’m using it for some month now and it worked fine all the time, normal site visitors don’t seem to be affected.
    Some of the previous posters wrote that it would not work.

    Probably they tested the rules against anonymous web proxies but the rewrite rules do not work with anonymous. However, you should know that a comment spammer almost always uses transparent (not anonymous) proxies, they simply cannot use anonymous for some reason. So you should test your rules against transparent proxies and it will work if you’ve done it correctly.

  5. James says:

    I tested these codes against http://www.superproxy.com.ar/ but does not work!

  6. delonix says:

    Doesn’t work for the few proxies I tried with

  7. A few years ago I looked for a good solution to block proxy servers. Also found that .htaccess solution, but as several state it is not working that well. Based on that I made my own solution, that I have now made available on its own website – take a look if you want. You can try it for free: http://www.blockthatproxy.com

    There is a free membership available where you can try, also there is a page where you can test if it can detect the proxy server.

  8. liliag says:

    What if I don't want to block a proxy server? I'd like to be able to use proxies so that my search engine won't jam no more. I'm referring, of course, to Google an their new Captcha policy. I'm working on a network with another 86 people so I always get asked if I'm human or not whatever I might be searching for. Any ideas?
    Lilia Gephardt @ Virtual private server

Leave a Reply

blog comments powered by Disqus
Subscribe to RSS Feed Follow me on Twitter!
Get Adobe Flash playerPlugin by wpburn.com wordpress themes
Thank you for using IGIT Tweet Share Button, a plugin by HackingEthics