Anyone know how to write VBScript?

BowDown

Banned
Jun 2, 2000
2,197
0
0
I need to make an ASP file that will take the domain that the browser is currently using and store it in an array. Then I want it to compair it to (3) pre-defined domain names. And if it matches one (which it will) I want it to load up a given url.

Here's a Psudeo code outline.

If someone types in http://www.testing.com, I want it to check the following:

-is it http://www.whoknows.com? if so load http://www.whoknows.com/whoknows/
-else is it http://www.whocares.com? if so load http://www.whocares.com/whocares/
-else is it http://www.testing.com? if so load http://www.testing.com/testing/

I have (3) domain names pointing to one IP. I want to have an app that will check to see what domain name was typed and send you off to the domain and subfolder where the site resides.

LMK... thanks!
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
Also I might have made that sound like it's a stand alone app. It's not. I want it to load as the home page when someone types in a domain name, then the file will read the domain name from the browser and automatically determine where to go from there.

Thanks! :)
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Well, this is one way to do it.

Select Case Request.ServerVariables("HTTP_REFERRER")
Case "www.somewhere.com"
Response.Redirect "somewhereelse.asp"
Case "www.somewhereelse.com"
Response.Redirect "somewhereagain.asp"
End Select

Of course, you'll need to verify that it's the server variable 'HTTP_REFERRER' that holds the appropriate information, as I can't check right now.
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
Sounds good so far... I'll run that by my programming teacher today. I wish I was learning VB, but instead I had to take a C course to start. Anyone want a Console app? LOL :).
 

I have a backload of "Hello World" apps I need to get out by the end of the month. Need a job?
 

pmark

Senior member
Oct 11, 1999
921
1
81
You want ServerVariables("server_name") not ServerVariables("HTTP_REFERRER")

HTTP_REFERRER gives you the url that they are coming from while server_name gives you the domain name of the url that they typed in.

Oh and server_name doesn't give you the "www."

So to copy Frost's code:

Select Case Request.ServerVariables("server_name")
Case "somewhere.com"
Response.Redirect "somewhereelse.asp"
Case "somewhereelse.com"
Response.Redirect "somewhereagain.asp"
End Select

 

BowDown

Banned
Jun 2, 2000
2,197
0
0
Maybe Dwell. Drop me an e-mail... You will be the second board member that I have done homework for (another bbs). :)

I will try this script out tonight. Thanks :).

All I have to do it cut and paste this into notepad and assign it an ASP extention right? There's no header files or anything?

 

DAM

Diamond Member
Jan 10, 2000
6,102
1
76
suggestion:

could this been done in jscript? and perhaps would have been easier?



just a thought.




dam()
 

pmark

Senior member
Oct 11, 1999
921
1
81
Dam,

That depends if you know jscript or not ;)

Ok BowDown just copy this:

<%
Select Case Request.ServerVariables(&quot;server_name&quot;)
Case &quot;whoknows.com&quot;
Response.redirect(&quot;http://www.whoknows.com/whoknows/&quot;)
Case &quot;whocares.com&quot;
Response.Redirect(&quot;http://www.whocares.com/whocares/&quot;)
Case &quot;testing.com&quot;
Response.Redirect(&quot;http://www.testing.com/testing/&quot;)
Case Else
End Select
%>

That should work by just pasting it into a asp file, granted I didn't test it...

Any questions, just email at pmark1999@hotmail.com

 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Ok, so it was &quot;server_name&quot; and not &quot;http_referrer&quot;

I said I wasn't sure :) Let us know if you have any more questions...
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
Thanks it works great. I think I may have to pick up a VB book and learn a language I can use... English is such a waste... Opps I ment C. ;)

Also I had to add a Case switch to handle the www.whatever.com. It works great if you just enter the whatever.com, but if you use the www it doesn't link.

It was no prb. Thanks :).