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….

  • Butters

    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)

  • Butters

    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)

  • Adam

    It doesn’t work.

  • Adam

    It doesn’t work.

  • Peter Vander

    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!

  • Peter Vander

    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!

  • Pingback: How to Block Proxy Servers using .htaccess | Blogging Tips by TeraTips.com()

  • NettiCat

    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.

  • http://http//netticat.ath.cx NettiCat

    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.

  • James

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

  • James

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

  • http://www.delonix.com.au/ delonix

    Doesn’t work for the few proxies I tried with

  • http://www.delonix.com.au delonix

    Doesn’t work for the few proxies I tried with

  • http://www.blockthatproxy.com/ BlockThatProxy.com

    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.

  • http://www.blockthatproxy.com BlockThatProxy.com

    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.

  • liliag

    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

  • Pingback: How to stop proxy servers ? - Webmaster Forum()

  • http://twitter.com/pileofcrap Billy Engler

    Strangely, this was working for me when I first implemented the code on my site. I just found this site, though, as I am looking for a new solution. For some reason… it no longer works.

  • Jomardyan

    its don’t working :((( 

  • Ashish

    Its now working for me in any condition.Please let me know how can i make it workable…