• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Do you know alternative of this option in WordFence?

mader

Well-known member
Babiato Lover
Trusted Seller
Trusted Uploader
Sep 18, 2019
601
468
63
Can anyone help?
I need to use similar option to "block IPs that access these URLs" which is built-in Wordfence plugin.
I do not want to use Wordfence
Did a broad research but can not find any alternative plugin or how to self code a similar "honeypot".

I need when someone visits a pre-defined url i.e. site.com/do-not-visit
than the IP address of that person/bot to be auto blocked from accessing the website.

Any ideas ?
 
I'm not sure about a WordPress security plugin. However, you can achieve this by creating a php file on your server, then setting up a redirect within WordPress/SEO Plugin, htaccess etc. to direct them to the php file once someone visits: "site.com/do-not-visit" --> "site.com/block.php"

Inside your block.php, you will need to log the IP address first of all:
Code:
<?php
    $at = $_SERVER['REMOTE_ADDR'];
    // This will create a blockedips.txt on your server
    $log = file_get_contents("blockedips.txt");
    $log = trim($log); // removes leading/trailing blank lines
    $log = explode("\n", $log);
    $log[] = $at;
    $log = array_unique($log);
    $log = implode("\n", $log);
    file_put_contents("blockedips.txt", $log);

    // Show a message?
    echo "Access Denied";
?>

Then you can add this into your theme header to read the file.
Code:
<?php
    $ipArray = file('blockedips.txt', FILE_IGNORE_NEW_LINES);
    $allowed = true;
    foreach ($ipArray as $ipTest) if ($_SERVER['REMOTE_ADDR'] == $ipTest) $allowed = false;
    // Block them if they are in the file
    if ($allowed != true) {
    header('HTTP/1.0 403 Forbidden');
    die();
}
?>

Finally, add your paths to the ''robots.txt'' to prevent bots crawling and getting blocked:
Code:
User-agent: *
Disallow: /block.php
Disallow: /do-not-visit/

Edit: You could also use RewriteMap if you have a compatible server
 
Last edited:
  • Like
Reactions: mader
Thank you, this sounds plausible I am going to try it out!
 
  • Like
Reactions: Knights
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock