How to Protect a WP Site to be Hacked by SQL Injection

How to Protect a WordPress Site to be Hacked by SQL Injection is a big question today as a lot of sites are launching with WordPress. WP site hacking by SQL Injection is a Panic to the site owners. Already a lot of famous and big sites have been hacked by SQL Injection. So now I think that you have understood the necessity to protect a site from SQL Injection and it must be stopped to secure a site from hacking.

How to Protect a WP Site to be Hacked by SQL Injection

If you want to know that how a WordPress site can be attacked by SQL Injection then you can take the help of search engines. You can also know about it by watching the YouTube video from Here.

So today I will show you how to how to Protect a WordPress Site to be Hacked by SQL Injection.

SQL Injection

At first open the .htaccess file of your site. You can open it in two ways, One– by logging to your WordPress Site’s Dashboard. Second– By logging to the cPanel of your site. Anyone you can choose.

Now copy the below code and paste it in .htaccess file. You can paste it at the end or where you think suitable.

N.B. Of course take the backup of .htaccess file before using this code. If it not work or show any site error then take the help from backup. It will save your site from unwanted error.

# protect from sql injection
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]

Now save the .htaccess file. You have completed your job. Now your WordPress site is save from SQL Injection. If you have any question or feedback then please comment in the comment section. Your feedback is truly needed for every visitor. Like us on Facebook or follow on twitter.

2 thoughts on “How to Protect a WP Site to be Hacked by SQL Injection”

  1. Very interesting blog. A lot of blogs I see these days don’t really provide anything that attract others, but I’m most definitely interested in this one. Just thought that I would post and let you know.

    Reply

Leave a Comment