Cookie Consent by Free Privacy Policy Generator

Block visitor IP or bot user agent with IF Statement PHP

Block a visitor's IP address from viewing a webpage or website with the PHP snippet below.
Code:
<?php
if ($_SERVER['REMOTE_ADDR']=="90.6.400.191"){
echo "You do not have permission to view this page";
exit();
}
?>


Block a user agent from viewing or crawling a webpage or website with the PHP snippet below.
Code:
<?php
if ($_SERVER["HTTP_USER_AGENT"]=="googlebot"){
echo "You do not have permission to crawl this page";
exit();
}
?>
 
Hello Chris,

I have a redirect script on my website, i tried using this your method to block visitors IP and Block all user agent from viewing or crawling the redirect script but unfortunatly is not working..

Please send me a message on telegram @nothing009890 or Email me. jonnyzea3@gmail.com for me information. i will pay for the service if u can help me out...
 
Back
Top