How do I show the domain name in address bar

Discussion in 'General troubleshooting' started by iguta, Mar 9, 2009.

  1. I am a new user who has just created my first redirect script.
    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]script [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]runat[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]="server"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
    [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Page_Init([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Object[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Src, [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] E)[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]((Request.ServerVariables[[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HTTP_HOST"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]]).Replace([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"www."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]))[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"site1.com"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:[/SIZE]
    [SIZE=2]Response.Redirect([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"http://...discountasp.net/Websites/site1/"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE]
     
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"site2.com"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:[/SIZE]
    [SIZE=2]Response.Redirect([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"http://...discountasp.net/Websites/site2/"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE]
     
    [SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"site3.com"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:[/SIZE]
    [SIZE=2]Response.Redirect([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"http://...discountasp.net/Websites/site3/"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE]
    [/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
    default[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:[/SIZE]
    [SIZE=2]Response.Redirect([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"http://...discountasp.net/Websites/site1/"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]script[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
    [/COLOR][/SIZE]
    While the script works the address bar shows
    Code:
    [COLOR=#a31515]http://...discountasp.net/Websites/site1/[/COLOR]
    How do I make the address bar display the domain www.site1.com instead?

    Kind regards
     
  2. Joseph Jun

    Joseph Jun DiscountASP.NET Staff

    You'll want to update your script to the following:

    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]script [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]runat[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]="server"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
    [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Page_Init([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Object[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Src, [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] E)[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]((Request.ServerVariables[[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HTTP_HOST"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]]).Replace([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"www."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]))[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"site1.com"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:[/SIZE]
    [SIZE=2]Response.Redirect([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"http://site1.com/Websites/site1/"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE]
     
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"site2.com"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:[/SIZE]
    [SIZE=2]Response.Redirect([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]http://site2.com[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]/Websites/site2/"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE]
     
    [SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"site3.com"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:[/SIZE]
    [SIZE=2]Response.Redirect([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"http://site3.com/Websites/site3/"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE]
    [/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
    default[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:[/SIZE]
    [SIZE=2]Response.Redirect([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"http://site1.com/Websites/site1/"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]script[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][/COLOR][/SIZE]
     
  3. That takes me halfway there, the address bar now reads
    Code:
    http://site1.com/Websites/dev_site1/
    I think even if I were to remove the Websites folder, the address bar would still show the site folder. Is there a way to re-write the URL so that visitors simply see
    Code:
    http://site1.com
    and have it point to the corresponding/correct web application.
     

Share This Page