Anidazen Posted March 29, 2007 Share Posted March 29, 2007 Hello. Firstly - yes I have Googled this and spent quite a while trying to understand these complicated HTACCESS rewrite engines and stuff, and it just completely escapes me. Is anyone able to create for me a line that will block 74.6.0.0 - 74.6.255.255 (all the 74.6's) from accessing http://www.mydomain.com/myfile.php5 and redirect them to http://www.mydomain.com ? I'm trying to do this because I have a file that uses MASSIVE resources, and it's being hit repeatedly by Inkitomi's bot, in clear violation of robots.txt. This usage is costing me a fortune. The same principle will be used to any other bots doing this. Permenant redirect would be best ofc. Link to comment https://forums.phpfreaks.com/topic/44796-redirect-certain-ip-range-to-homepage/ Share on other sites More sharing options...
per1os Posted March 29, 2007 Share Posted March 29, 2007 Place this one in your root: ErrorDocument 403 /errorpages/redirect.php order allow,deny allow from all deny from 74.6. #ips here Place this in your errorpages directory. order deny,allow allow from all Place this also in errorpages dir <?php // redirect.php if (ereg("74.6.", $_SERVER['REMOTE_ADDR'])) { header("Location: http://www.mydomain.com"); }else { die("INTERNAL SERVER ERROR!"); } ?> Link to comment https://forums.phpfreaks.com/topic/44796-redirect-certain-ip-range-to-homepage/#findComment-217504 Share on other sites More sharing options...
per1os Posted March 29, 2007 Share Posted March 29, 2007 Thinking about it the above will deny all pages to that person. If you want to block a certain IP address from a page add this to the top: <?php //myfile.php5 if (ereg("74.6.", $_SERVER['REMOTE_ADDR'])) { header("Location: http://www.mydomain.com"); } ?> That will take them away from the myfile.php5 page without the need for .htaccess Link to comment https://forums.phpfreaks.com/topic/44796-redirect-certain-ip-range-to-homepage/#findComment-217508 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.