Help with redirect for certain IP's

B

bryant_j_j

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.
 
A

Aaron Gray

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
 
R

Roman Ziak

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top