473,378 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Help with redirect for certain IP's

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 '06 #1
2 1934
<br********@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
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
Apr 9 '06 #2
br********@yahoo.com 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>
Apr 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Mike | last post by:
I'm used to unix/cgi scripts so im slightly out of my depth here. Ive got an asp script for a website form which works fine. What i want to do is also get the form to include the ip address of the...
18
by: | last post by:
Please help. After a number of wrong turns and experiments I need advice on login management system to secure our web pages without inconveniencing our visitors or our internal staff. What I...
6
by: \A_Michigan_User\ | last post by:
Ok, I give up... why do 1-4 work fine... but 5-6 give "can't find" errors? 1. Client-side VBscript code: call navigate("\\209.11.22.33\MyDir") 2. Client-side VBscript code: location.href...
1
by: jonathanthio | last post by:
Do anyone knows how to redirect based on IP? Things like if (user.ip=202.23.23.4){ window.location="go here" }
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: MikeM | last post by:
We are getting a behavior on a Response.Redirect("SomeUrl", True) that I'm hoping someone can explain. This all refers to the code snip at the end. By the way, this is all VB ASP.NET v1.0 code. ...
19
by: IveCal | last post by:
Hello, I have this code which redirects to http://www.domain.com/link.html . . . but I want to specify the NUMBER OF SECONDS before the site is redirected. Can somebody here help me . . .. ...
12
by: smerf | last post by:
I have searched high and low (and even in some places I'd like to forget I ever saw) for the information that will tell me exactly how the Nat2Nat server for UltraVNC works (not just a vague...
1
by: Trev | last post by:
Hi everyone, I'm trying to modify an existing piece of Javascript that will enable a redirect to a page based on IP address and/or keywords in the referrer; for instance, redirecting an existing...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.