WordPress is always very target for hackers. Hackers always use the proxy servers to access the wordpress websites. Hackers attack the wordpress sites using the proxy IP addresses and servers. Here Using small trick you can prevent the proxy server attack. This is very easy trick which can be used in every wordpress project.

block proxy servers to access wordpress

All proxy visits are not bad requests so First check the site access logs. If you are thinking Your site attacked by Hackers and proxy servers then only use the following code.


You just need to add following code into your .htaccess file. You can open your .htaccess apache configuration file from wordpress root folder.

<IfModule mod_rewrite.c>
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]

After adding above code you must check your wordpress site. Check the your every pages of your site. Check your sites pages on atleast on three PCs so you will sure about your site and above code.

Open your header.php file which you find in your wordpress theme folder.

Take backup header.php file first.

<?php if(@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1)) die("Proxy access not allowed"); ?>

Put above code in header.php file and check your site is working fine. There are so many articles written on same topic so you can check those also before making any changes.

block proxy servers to access wordpress

block proxy servers to access wordpress

Written by Purab

My name is Purab, Here is my Personal Blog: wpapi.com. I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to purabdk@gmail.com or Chat with me on Skype : purabdk

This article has 1 comment

Leave a Comment

Your email address will not be published. Required fields are marked *