Help with redirect for certain IP's

Discussion in 'Javascript' started by bryant_j_j@yahoo.com, Apr 9, 2006.

  1. Guest

    Hi everyone,

    Does anybody know how to redirect every visitor to a webpage, except
    those coming from some specified IP addresses, to a different webpage?
    Does anybody know of a JavaScript for this or how to do it?

    For example, I want everyone who visits www.someaddress.org/myhomepage
    to be redirected to www.someaddress.org/myhomepage /index2.html, except
    for certain visitors with IP addresses A1.B1.C1.D1, A2.B2.C2.D2, ...
    or from a range of IP addresses such as A1.B1.C1.XXX, where XXX is any
    3 digits (I do not want these guys to be re-directed) ...

    TIA, J.
    , Apr 9, 2006
    #1
    1. Advertising

  2. Aaron Gray Guest

    <> wrote in message
    news:...
    > Hi everyone,
    >
    > Does anybody know how to redirect every visitor to a webpage, except
    > those coming from some specified IP addresses, to a different webpage?
    > Does anybody know of a JavaScript for this or how to do it?
    >
    > For example, I want everyone who visits www.someaddress.org/myhomepage
    > to be redirected to www.someaddress.org/myhomepage /index2.html, except
    > for certain visitors with IP addresses A1.B1.C1.D1, A2.B2.C2.D2, ...
    > or from a range of IP addresses such as A1.B1.C1.XXX, where XXX is any
    > 3 digits (I do not want these guys to be re-directed) ...
    >
    > TIA, J.


    Best to do that server side, not sure if it can be done client side.

    Aaron
    Aaron Gray, Apr 9, 2006
    #2
    1. Advertising

  3. Roman Ziak Guest

    wrote:
    > Hi everyone,
    >
    > Does anybody know how to redirect every visitor to a webpage, except
    > those coming from some specified IP addresses, to a different webpage?
    > Does anybody know of a JavaScript for this or how to do it?
    >
    > For example, I want everyone who visits www.someaddress.org/myhomepage
    > to be redirected to www.someaddress.org/myhomepage /index2.html, except
    > for certain visitors with IP addresses A1.B1.C1.D1, A2.B2.C2.D2, ...
    > or from a range of IP addresses such as A1.B1.C1.XXX, where XXX is any
    > 3 digits (I do not want these guys to be re-directed) ...
    >
    > TIA, J.
    >


    Do a HTTP request to http://www.whatismyip.org/ and based on the result
    assign window.location.

    However, more elegant would be server-side, which will work regardless
    on client javascript enabled or not

    <ot>

    <?php
    if($_SERVER['REMOTE_ADDR'] == '127.0.0.1')
    header('Location: 'index2.php');
    ?>

    </ot>
    Roman Ziak, Apr 10, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S2VudGFtYW5vcw==?=
    Replies:
    6
    Views:
    1,162
    Kevin Spencer
    Mar 5, 2004
  2. Replies:
    0
    Views:
    645
  3. Replies:
    2
    Views:
    517
    bruce barker
    Mar 25, 2008
  4. Sal
    Replies:
    1
    Views:
    403
  5. SAN CAZIANO
    Replies:
    8
    Views:
    174
    Dr John Stockton
    Oct 15, 2004
Loading...

Share This Page