Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASP Redirection script
06-07-2006, 04:10 PM
Post: #1
ASP Redirection script
I am trying to put a redirection script on our webserver so that anyone coming from an internal address (10.0.XX.XX) gets send to one page and anyone coming from any other range gets sent to a different page.

here's what someone set up for me:

Code:
<%
var ipAdd = Request.ServerVariables("REMOTE_ADDR");

if(ipAdd.substr(0, 4) == "10.0")
{
    Response.Redirect("http://localhost/seditio/index.php");
}

else
{
Response.Redirect("http://<external ip of server>/citrix/metaframexp/default/login.asp");
}



%>

I have change the external ip of our server for safety reasons

Now he said it should work, but for some reason I am getting this error:

Quote:HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

Technical Information (for support personnel)

* Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/redir.asp, line 2, column 50

* Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4

* Page:
GET /redir.asp


Any help is appreciated!

- Techmonkey
================
Enterprise Business IT Support | SME IT Support | Home Support Available
Send this user an email Visit this user's website Find all posts by this user
Quote this message in a reply
06-07-2006, 04:52 PM
Post: #2
 
Um, for one you can't redirect to localhost! It might work on that server, but anyone else connecting to it will get redirected to THEIR localhost, not yours.

For two, he's written that in C#, and you seem to be trying to execute it as ASP. Rename it to .aspx, assuming your server handles .NET, and it should work.

Give me liberty, or give me death - Patrick Henry 1775.
Think for yourselves and let others enjoy the privilege to do so too - Evelyn Beatrice Hall 1906
I spread my wings, only to find that they are paper in the rain - Neko 2006
Send this user an email Visit this user's website Find all posts by this user
Quote this message in a reply
06-07-2006, 05:21 PM
Post: #3
 
Well we're getting closer.....

Code:
<%
var ipAdd = Request.ServerVariables("REMOTE_ADDR");

if(ipAdd.substr(0, 4) == "10.0")
{
    Response.Redirect("http://xxxxxxx");
}

else
{
Response.Redirect("http://xxxxxx");
}



%>

However internal users are getting to: http://xxxxxxxx

- Techmonkey
================
Enterprise Business IT Support | SME IT Support | Home Support Available
Send this user an email Visit this user's website Find all posts by this user
Quote this message in a reply
06-07-2006, 06:56 PM
Post: #4
 
Have you tried simply renaming it with a .aspx extension?

*EDIT* Nevermind, that var kinda gives it away as not being the problem Tongue

The error is fairly simple: it's a VB parsing error, but that is not VB syntax. As Shultz informs me, it is the javascript syntax of ASP. Check your IIS settings, make sure it expects this.

Give me liberty, or give me death - Patrick Henry 1775.
Think for yourselves and let others enjoy the privilege to do so too - Evelyn Beatrice Hall 1906
I spread my wings, only to find that they are paper in the rain - Neko 2006
Send this user an email Visit this user's website Find all posts by this user
Quote this message in a reply
06-07-2006, 07:38 PM
Post: #5
 
Code:
<%@ Language=JavaScript%>

<%
var ipAdd = String(Request.ServerVariables("REMOTE_ADDR"));


if((ipAdd.substr(0,3)) == "192")
{
   Response.Redirect("http://www.google.co.uk");
}

else
{
Response.Redirect("http://www.1car1.com");
}

%>

try that KiD resolves the issue with it trying to parse as VB by explicitly naming the language as JavaScript and also has the string() parsing method that was in my original code but not in yours for some reason.

Check Out Car Hire in Leeds and don't forget to check out my personal blog Fearless Shultz
Send this user an email Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: