Created
November 20, 2023 23:34
-
-
Save esedic/52d35b54366b2e8000877df7c7442656 to your computer and use it in GitHub Desktop.
Prevent PHP execution if USER_AGENT is bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// While not foolproof, you can check the USER_AGENT string and only run that code if 'bot' does not exist. | |
if(stripos($_SERVER['HTTP_USER_AGENT'],'bot') === false){ } | |
// This would stop any bot that actually has bot in the user agent string that also does not pay attention to robots.txt. | |
// Source: https://stackoverflow.com/a/17600047/1090042 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment