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.

# BLOCK PROXY VISITS
<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]
</IfModule>

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 WPAPI

My name is Purab Kharat, Here is my Personal Blog: digcms.com. Work as an Senior Technical Lead at Smartsourcing Global Pvt Ltd in Princeton, NJ, USA. I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to purab 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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>