Forum Moderators: DixonJones

Message Too Old, No Replies

Inside or outside the domain?

         

John_Moore

7:27 pm on Sep 16, 2005 (gmt 0)

10+ Year Member



Could any body help me solve a little problem I am having?

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"?

larryn

9:02 pm on Sep 16, 2005 (gmt 0)

10+ Year Member



John,

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

John_Moore

8:28 am on Sep 17, 2005 (gmt 0)

10+ Year Member



The school uses a Windows server purchased this summer and all pc's in the school are running XP
All are in the same ip block.

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

larryn

4:53 pm on Sep 17, 2005 (gmt 0)

10+ Year Member



John,

Look into the document.href.location element - setting it to a specific value will display that page.

Larry

John_Moore

8:26 am on Sep 18, 2005 (gmt 0)

10+ Year Member



Thanks for that, I think I've cracked it now

Eltiti

8:41 am on Sep 18, 2005 (gmt 0)

10+ Year Member



John,

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.

larryn

3:46 pm on Sep 18, 2005 (gmt 0)

10+ Year Member



Eltiti,

Thats a really good solution!

Eltiti

4:07 pm on Sep 18, 2005 (gmt 0)

10+ Year Member



Thanks larryn! :-)

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