Jump to content

Redirect certain IP range to homepage?


Anidazen

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.