Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect URL script

Status
Not open for further replies.

wlfpackr

IS-IT--Management
May 3, 2003
161
0
0
US
Hopefully this is an easy one for you as my ASP/VBScripting is VERY rusty. I want to use an ASP script to redirect the web site visitor depending on what subdomain they enter. So let's say you have a site called XYZ.com. i.e. if the user types in it hits an index.asp script first which is a simple IF THEN script that would tell the browser...

If is URL go to ..\index.html
If users.xyz.com is URL go to ..\users\index.html
If support.xyz.com is URL go to ..\support\index.html

Many moons ago I remember writing a script for a web site that did this, but I haven't written any VB code in so long I can't for the life of me remember how I did it.

=================
There are 10 kinds of people in this world, those that understand binary and those that do not.
 
If interested, here was the code I used.

Code:
 <%@ Language=VBScript %>
    <% response.buffer = True %>
    <%

'This script will redirect a user to a particular part of the website
'Depending on what URL they typed in.
'


'Create variables
     Dim strURL		'This is the URL the user typed into the browser
    
'Assign user-typed URL to variable strURL
     strURL = Request.servervariables("HTTP_HOST")
    

If strURL = "[URL unfurl="true"]http://users.xyz.com"[/URL] THEN
     Response.Redirect "[URL unfurl="true"]http://www.xyz.com/users/index.html"[/URL]

Else If strURL = "[URL unfurl="true"]http://support.xyz.com"[/URL] THEN
     Response.Redirect "[URL unfurl="true"]http://www.xyz.com/support/index.html"[/URL]

Else 
     Response.Redirect "[URL unfurl="true"]http://www.xyz.com/index.html"[/URL]

End If



    %>

I changed some of the information in there so hopefully I didn't end up with any typos.

=================
There are 10 kinds of people in this world, those that understand binary and those that do not.
 
Seems to me you can do this on the server (instead of in a script) as well...

ummm.... multi-homing does it all the time.

So you could have xyz.com and abc.com on the same server....



Just my 2¢
-Cole's Law: Shredded cabbage

--Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top