Redirect IP Address using htaccess
Redirect IP Address Using htaccess to get rid of annoying visitors that come to leave you spam. Better yet would you not like to tell them off with a web page especially for them? You can even redirect an entire country to a certain page or even another website altogether using htaccess. I decided to do this tutorial because there are a lot of people out there getting harassed by hackers and spammers. This can be your way of telling them off, lol. You can also use this as a tool to reward those people who come to your site a lot by directing them to a thank you page. If you are multi-lingual you can even have a page just for those foreign speaking visitors. Use your imagination and the sky is the limit. The following method only works on Linux servers with Apache installed. Windows servers do not support htaccess.
Step 1 Set your page up that you want certain people to be directed to.
http://getoffmysite.com http://thanksforvisiting.com
Step #2
Figure out what Redirect IP Address you want to redirect. In wordpress you can do this by clicking on your comments section in your dashboard. All the ip addresses are listed right under the users name. If you have cpanel go to logs then recent visits if you know they person was just on your site, you will be able to see what pages they visited to give you an idea of who they are. Step #3
Look the person up in the whois database. This will give you a lot of valuable information about the person. Step #4 After you are sure about the ip address find your .htacces file in your root folder. You can access it via a ftp program like filezilla. You may have to go into your cpanel and set up a ftp log in if you don't have one. You can contact your hosting provider and they will walk you through the process. I will have a tutorial on this very soon. Now find your .htaccess file and download it to your computer. Step #5
Now double-click and edit the .htaccess file by entering this code. you can use notepad or download notpad++ here.
# permanently redirect specific IP request for entire site Options +FollowSymlinks RewriteEngine on RewriteCond %{REMOTE_HOST} 22\.22\.22\.239 RewriteRule \.php$ http://www.destinationwebsite.com/ [R=301,L]Or if you want to redirect a whole range of ip address use this code.
# permanently redirect ranged IP request for single page RewriteEngine On RewriteBase / RewriteCond %{REMOTE_HOST} 22\.22\.22 RewriteCond %{REQUEST_URI} page-with-form-on.php$ RewriteRule .* http://www.destinationwebsite.com/ [R=301,L]Step #6
Upload the .htaccess file in the exact same folder where you got it from. #ff0000;">warning!!! do not upload to another folder! #000000;">Redirect IP Address is so much fun! Now your all done, it's just too bad you cannot see the look on the hackers face when they been hacked. ;-) If you want to say updated on more WordPress tutorials and more subscribe to my feed and we will email them to you as we post them.