If not IP redirect to holder.html

Discussion in 'Apache' started by WiBu, May 1, 2007.

  1. #1
    I've had a good old search around the web and I've come up more or less empty handed. I'm posting here in the hope that someone will help me out.

    I'm trying to redirect all people who don't aren't a certain an IP (mine) to a page called holder.html using a 302 (temp) redirect using .htaccess.

    I have found this snippet but it doesn't seem to be working for me (and it doesn't seem correct):
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REMOTE_HOST} !^123\.45\.67\.89
    RewriteCond %{REQUEST_URI} !/holder\.html$
    RewriteRule \.html$ /holder.html [R=302,L]

    Any help appreciated, a salution even more so.
     
    WiBu, May 1, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you tried using a full URL as the redirect destination? Either that or specify the RewriteBase.

    Also, that should only redirect .html pages - is that what you wanted?
     
    rodney88, May 1, 2007 IP
  3. WiBu

    WiBu Member

    Messages:
    48
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I just did but it doesn't seem any different. The code I posted above doesn't seem to be denying any IPs. I suspect that it might all be wrong.

    Heh, nope. I want it to redirect everything. If you haven't noticed already I'm a .htaccess newbie but I'm trying to learn.
     
    WiBu, May 1, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ah yeh, the variable name is wrong. It should be REMOTE_ADDR, not REMOTE_HOST.
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REMOTE_ADDR} !^123\.45\.67\.89$
    RewriteCond %{REQUEST_URI} !/holder\.html$
    RewriteRule .* http://www.domain.com/holder.html [R,L]
    Code (markup):
     
    rodney88, May 1, 2007 IP
  5. WiBu

    WiBu Member

    Messages:
    48
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    Perfect. Thanks a lot.
     
    WiBu, May 1, 2007 IP