SUCCESS - You are likely no bot, you may pass!


This is an example usage of the "botsec.php" script. It'll redirect you to https://www.google.com/ if the user-agent of the request is in the array defined in the file called "botsec.def.php" or defined in the url / file "https://botsec.kimhauser.ch/bots2ignore.txt" - depends on your setting in the config.php file - and so one of the following strings:

Testing the script

You can test the botsec.php script with your own User-Agents like so:

Setup the BotSec script:

  1. Copy the files to a directory of your choice
  2. Amend the config.php file and:
    • Set whether to load agents2ignore from URL or botsec.def.php
    • Amend the botsec.def.php or the https://botsec.kimhauser.ch/bots2ignore.txt with you own agents
    • Set the URL to redirect request from ignored user agents to
  3. Include botsec.php in your index.php or other startup PHP-scripts that will be loaded for the requests in question

Start Test-Server locally:

  1. Goto the directory containing the files in a terminal
  2. Execute "php -S 127.0.0.1:8888" in the terminal
  3. Open the address "127.0.0.1:8888" with your Webbrowser of choice
  4. Now you should see the success message
  5. With Google Chrome you can amend the User-Agent for the Request like so
    1. Open the developer console of Google Chrome with CMD+Option+J (macOS)
    2. In the developer console click the three dots in the upper right corner
    3. Click on "More Tools" > "Network Conditions"
    4. In the bottom panel you should see the User-Agent and you can change it to a custom agent

Github repo of "botsec.php" script


Version history of BotSec