Forum Moderators: DixonJones
I need to be able to detect whether our school website is being viewed from within school (within our domain) or from outside school (outside the domain)
If a web page is viewed from inside school, I wish to redirect pupils/staff to one page and if viewed from from outside school, I wish to redirect staff/pupils to another web page.
Is there a little script anybody can send me to save me HOURS of frustrating "FUN"?
What platform are you using? That might help someone suggest a specific solution, but the quick answer relates to how your school network is set up.
- Is everyone on the same IP block? If so, you can test for the host IP in any language
- Is eveone on the same Domain? If so, you can test that but you might require a reverse DNS lookup which can be timeconsuming.
Good Luck,
Larry
What I need is a little piece of code that I will place on our index page to allow a redirect to either one page or another. I am no Javascript expert so I need all the help I can get
Thanks
A JavaScript solution may work, but it is not "secure", because it is client-side. If it is important that "outsiders" can't see the inside content, it would be better to use a server-side solution, e.g.:
IP = Request.ServerVariables("REMOTE_ADDR")
If IP <> "123.45.54.123" Then
Server.Transfer "somepage.asp"
Else
Server.Transfer "anotherpage.asp"
End If
in VBScript.
I should add the following, in the interest of completeness. My original suggestion assumes that your server supports ASP 3.0, so that you can use Server.Transfer.
If it does *not* (i.e., if you're still on ASP 2.0), you should use:
Response.Redirect "somepage.asp"
Response.End
instead of Server.Transfer "somepage.asp" (the Response.End looks superfluous, but it solves some problems you may otherwise encounter).