All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
multiple,domain,names,pointing,same,site,code
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 287,569. lines
 Jobs: 118. postings

 How to support the site

 
Sponsored by:
Quick Search for:  in language:    
You are in:
 
Login


 

 


Latest postings for ASP/ VbScript.
A simpla ASP Login & Logout Page of E-commerce website for Registred Users
By SJPVTLTD.COM on 2/2


A simplem ASP Login Page for Registered User
By SJPVTLTD.COM on 2/2


Click here to see a screenshot of this code!The Real Estate - Search Engine
By Talal Hussain Al-Balushi on 2/1

(Screen Shot)

A simple ASP Registeration Page for E-commerce Website
By Tejas Jayantilal Gandhi on 1/28


A simple ASP Forgot Password page for E-commerce Website
By Tejas Jayantilal Gandhi on 1/28


Simple ASP inquiry form for a simple or e-commerce website
By Tejas Jayantilal Gandhi on 1/28


A Simple ASP Change of Password Page for E-commerce Website
By Tejas Jayantilal Gandhi on 1/28


A simple ASP Login Page
By Tejas Jayantilal Gandhi on 1/27


Free ASP Shopping Cart Software for Small Business
By Tejas Jayantilal Gandhi on 1/27


ASP Daily Hit Counter
By Tejas Jayantilal Gandhi on 1/27


AS400 Connection
By Talal Hussain Al-Balushi on 1/26


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Multi Domain Redirect

Print
Email
 
VB icon
Submitted on: 10/10/2000 7:59:05 PM
By: Glenn C. 
Level: Beginner
User Rating: By 3 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 43810 times.
 
(About the author)
 
     If you have multiple domain names pointing to the same web site, this code will allow you to redirect the user to a subdirectory based on the web address then type in the browser.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Multi Domain Redirect
    ' Description:If you have multiple domai
    '     n names pointing to the same web site, t
    '     his code will allow you to redirect the 
    '     user to a subdirectory based on the web 
    '     address then type in the browser.
    ' By: Glenn C.
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=6349&lngWId=4    'for details.    '**************************************
    
    <%@ Language=VBScript %>
    <%
    ' Set up your variables
    Dim sURL, sPath
    ' Get the domain name typed in the brows
    '     er.
    sURL = Request.ServerVariables("HTTP_HOST")
    ' Get the rest of the path after the dom
    '     ain name.
    sPath = Request.ServerVariables("PATH_INFO")
    ' Based on the domain name, redirect the
    '     user
    ' to the correct directory and attach th
    '     e rest
    ' of the path.
    Select Case sURL
    	Case "www.maindomain.com", "maindomain.com"
    		' Ignore...this is the current site.
    	Case "www.domain2.com", "domain2.com"
    		' redirect To the "domain2" directory
    Response.Redirect "domain2" & sPath
    	Case "www.domain2.net", "domain2.net"
    ' redirect to the "domain2net" directory
    '     
    		Response.Redirect "domain2net" & sPath
    End Select
    %>

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
10/24/2000 11:13:33 AMZen

Good concept. Be careful though, because this can put undue wear and tear on a webserver (Like those god-awful netscape/IE JavaScript Redirects). You're better off just buying another box. Great, clean code tho!
(If this comment was disrespectful, please report it.)

 
1/22/2001 12:36:00 AMJoe

Great code, nice interface...
What about ViewTable.asp, it was not included with the zip file?
(If this comment was disrespectful, please report it.)

 
1/22/2001 9:43:23 AMGlenn

Uh...wrong code Joe.
(If this comment was disrespectful, please report it.)

 
8/9/2002 1:20:47 AMspydj@hotmail.com

can you explain me where I have to write my old and new adresse redirection in that code, tanks
(If this comment was disrespectful, please report it.)

 
8/9/2002 10:04:57 AMGlenn C.

spydj, are you talking about page redirection or domain redirection?

If it's domain redirection, put your domains in the Select Case and use Response.Redirect to send the browser to a sub-folder.

If you are talking about page redirection, you'll have to use Response.Redirect on each page you changed.
(If this comment was disrespectful, please report it.)

 
8/27/2002 12:34:34 PMBob Leffew

ncr.harwood-intl.com
lifekeeper.harwood-intl.com
lsi.harwood-intl.com
storagetek.harwood-in tl.com
genicom.harwood-intl.com
tally.harwood-intl.com
teradata.harwood-intl.com (All of the above IN A 208.55.177.28)

Question: Will your code work for us? Running NT. Would love for when a person clicks on a link it will show the address as (EX:) http://ncr.harwood-intl.com.

Would it be to much to give us an example.

Our ISP gave us your code and said the following: may use a combination of the Request.ServerVariables("HTTP_HOST") variable and Response.redirect command in ASP to accomplish the same effect of redirecting your subdomains to folders within your site.
(If this comment was disrespectful, please report it.)

 
8/27/2002 2:44:28 PMGlenn C.

uh.. Bob, you can't really do that.

This code was written so if you have domain1.com and domain2.com pointing to the same web site, you can redirect people to a different folder based on the domain.

A sub domain, such as ncr.harwood-intl.com, has to be setup on the server, otherwise it won't ever get to your script. Most hosts will give you the option of creating a subdomain, many times for free.
(If this comment was disrespectful, please report it.)

 
9/9/2002 8:20:55 PM

Sorry for the previous posting... :( .. Could you please tell me how I should name the script in my server?... I named it as default.asp and it redirects perfectly to mydomain2 but it shows a blank page when I type mymaindomain.. I created default.htm, index.htm and index.html in my server to see if the script opens mymaindomain, but I always get the same blank page.

Thank you in advance for your kind attention to this request.

Regards,

Juan Manuel
(If this comment was disrespectful, please report it.)

 
9/9/2002 8:47:03 PMGlenn C.

Juan, do you have any content on the default.asp page other than this script?

Your default.asp page should be your home page for the main domain, and simply display itself if the main domain is used. It only redirects if one of your other domains are used.
(If this comment was disrespectful, please report it.)

 
9/9/2002 9:33:19 PM

Thanks Glenn... I understood.. now I just placed the script in my default.asp page and it works GREAT... thank you very much for your fast response.. i really appreciatte your help...

Sincerely,

Juan Manuel
(If this comment was disrespectful, please report it.)

 
12/3/2002 12:45:06 AM

I used your code to redirect a second domain name on my account, but is it possible to carry the domain name with it? For example, www.tabbyweb.com is my main web on the account and www.slowtrips.com is a subweb. I used your script to redirect
(If this comment was disrespectful, please report it.)

 
12/3/2002 9:30:37 AMGlenn C

I'm not sure what you mean by
(If this comment was disrespectful, please report it.)

 
12/3/2002 9:32:58 AMGlenn C

Grr.. Let's try this again.

I'm not sure what you mean by "carry the domain". Could you restate the question?
(If this comment was disrespectful, please report it.)

 
12/3/2002 12:08:41 PM

Your input form cut off the last part of my message. Is it possible to get the domain name to carry thru with the redirect?
(If this comment was disrespectful, please report it.)

 
12/3/2002 12:11:03 PM

www.tabbyweb.com is the main domain. Redirects www.slowtrips.com to slowtrips subweb, but the URL is www.slowtrips.com/slowtrips/... Can I get it to not show the folder level - to see the subweb as a web of its own?
(If this comment was disrespectful, please report it.)

 
12/3/2002 1:09:24 PMGlenn C

Not with ASP. You need to setup the subdomain pointer with your host. Then the slowtrips folder will become the root folder for that domain.
(If this comment was disrespectful, please report it.)

 
12/3/2002 5:15:45 PM

Thanks! And thanks for providing the script!!
(If this comment was disrespectful, please report it.)

 
1/21/2003 2:07:07 PM

This is in regard of www.tabbyweb.com and www.slowtrips.com An ackward but effective way to hide the sub for slowtrips.com (which is going to be www.slowtrips.com/slowtrips/) is to create a FRAMESET in your default.htm page located in the root directory. The FRAMESET will contain only one FRAME pointing to default2.asp which will handle the redirect. <html> <head> <title> </title> </head> <frameset noresize rows=
(If this comment was disrespectful, please report it.)

 
1/21/2003 2:07:56 PM

the rest of the message: <html> <head> <title> </title> </head> <frameset noresize rows="*" frameborder="no" border="0" framespacing="0" marginwidth="0" marginheight="0"> <frame noresize src='default2.asp' name='frameRedirect' frameborder='no' border='0' marginwidth='0' marginheight='0' scrolling='no' align='top'> </frameset> <noframes> <body bgcolor="#FFFFFF">
Yuor browser must support frames to view this site.
</body> </noframes> </html> Hope this helps.
(If this comment was disrespectful, please report it.)

 
2/4/2003 3:03:55 PM

Hey,
Couldn't you just do something like the following for the maindomain.com:

Case "www.maindomain.com", "maindomain.com"
Response.Redirect default.htm
(If this comment was disrespectful, please report it.)

 
2/4/2003 3:57:09 PMGlenn C

That is basically what the code does, but this code also takes into account any additional path which may have been give, such as maindomain.com/help/info.html.

It's probably better to just setup a subdomain on your server... if possible.
(If this comment was disrespectful, please report it.)

 
4/13/2003 7:29:15 AM

This Code will redirect the to the particular folder checking the domain name. But will it show the redirected domain or the typed domain name in the address bar????
(If this comment was disrespectful, please report it.)

 
4/13/2003 7:31:18 AM

The Code checks the domain name and redirects to a particular folder. But what is address that will displayed on the address bar. The redirected address or the typed domain name????
(If this comment was disrespectful, please report it.)

 
4/13/2003 10:08:20 AMGlenn C

It will show the redirected address.
(If this comment was disrespectful, please report it.)

 
9/27/2005 12:50:43 PMRoy Hinkelman

Hi, and Thanks for offering this code.

Can you help a relative newby with instructions on how to install this code?

I want to place it in my index.html page. Does this code go between the head or body code?
(If this comment was disrespectful, please report it.)

 
9/27/2005 6:17:03 PMGlenn C.

This can only be used in an ASP page. It would be placed at the beginning of your index.asp or default.asp page.
(If this comment was disrespectful, please report it.)

 
4/29/2006 6:16:26 AMhugo

Please note the bedinning of the pages (fron "Submitted on" till "xxx times" does'nt display the right way with opera 8.54 browser.
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Games | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2010 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.