1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirecting certain IP's to 404 pages?

Discussion in 'BlackHat Lounge' started by superaff1984, Sep 30, 2011.

  1. superaff1984

    superaff1984 Power Member

    Joined:
    Jun 16, 2010
    Messages:
    619
    Likes Received:
    20
    Location:
    West Los Angeles, CA
    How can I redirect a certain IP address that visits our site to a 404 page. Or somehow to make that individual think our site is down?
     
  2. boxchevy

    boxchevy Newbie

    Joined:
    Dec 6, 2008
    Messages:
    17
    Likes Received:
    7
    .htaccess would probably be easiest

    Code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REMOTE_ADDR} ^255\.255\.255\.255
    RewriteRule ^(.*)$ xxxxxxxxxxxxxxxxxxxxxxxxxxxx/$1 [R=301,L]
    replace x's with your url (cant post urls yet didnt want to confuse by adding other characters to make it pass the filter)

    you can put in a specific ip or a range for ex:

    ^255\.255\.[0-2]{1}

    filters the first digit of the third number.
     
  3. superaff1984

    superaff1984 Power Member

    Joined:
    Jun 16, 2010
    Messages:
    619
    Likes Received:
    20
    Location:
    West Los Angeles, CA
    So this will make all page on the site or domain look like a 404 error?

    Let's say I want to block this IP range. How would I write it?

    I want to block 164.62.13.0/255 or whatever..
     
    Last edited: Oct 1, 2011
  4. superaff1984

    superaff1984 Power Member

    Joined:
    Jun 16, 2010
    Messages:
    619
    Likes Received:
    20
    Location:
    West Los Angeles, CA
    by the way when I put in my IP. It says the page is not redirecting properly.
     
  5. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    950
    Likes Received:
    662
    Occupation:
    Web/Bot Developer
    This should fix it.

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REMOTE_HOST} 123\.123\.123\.123
    RewriteCond %{REQUEST_URI} !/404.html$
    
     
  6. superaff1984

    superaff1984 Power Member

    Joined:
    Jun 16, 2010
    Messages:
    619
    Likes Received:
    20
    Location:
    West Los Angeles, CA
    It did not work. I replace it with my IP for testing and it returned my page just fine.
     
  7. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    950
    Likes Received:
    662
    Occupation:
    Web/Bot Developer
    This tested fine in Wordpress. Make sure you place this at the top of your .htaccess file and create a static html page as the lander for the redirect.

    Code:
    RewriteEngine On
    RewriteCond %{REMOTE_ADDR} ^123\.123\.123\.123$
    RewriteCond %{REQUEST_URI} !/page.html
    RewriteRule ^(.*)$ /page.html [R,L] 
    
     
    Last edited: Oct 1, 2011
  8. superaff1984

    superaff1984 Power Member

    Joined:
    Jun 16, 2010
    Messages:
    619
    Likes Received:
    20
    Location:
    West Los Angeles, CA
    Wait I think I know what's going on I confused everyone. I listed the title as "404 page." What I am trying to do is have the domain return with nothing. For example, go to www.eadfafdsafsd.com. My Firefox says it could not find it. That's what I'm trying to do only towards certain IP address.
     
  9. the_demon

    the_demon Jr. Executive VIP

    Joined:
    Nov 23, 2008
    Messages:
    3,177
    Likes Received:
    1,563
    Occupation:
    Search Engine Marketing
    Location:
    The Internet
    Almost every cPanel has a BanIP feature why not use that?

    ... I don't believe you can do it at the DNS level though which is what it sounds like your asking for.