redirection on a shared server?

Discussion in 'ASP General' started by Paul, Apr 18, 2005.

  1. Paul

    Paul Guest

    I am setting up 4 sites for a small business complex. They wanted to save
    money on hosting so asked to have all the sites under one hosting plan, but
    with independent domain names. I thought that would be easy, just set up a
    domain redirect to a specific folder on the server. Unfortunately I have
    since learned that the host does not provide that level of redirection.

    Let's say my 4 sites are: restaurant.com, coffeeshop.com, dayspa.com and
    bizcomplex.com. The hosting account is set up for bizcomplex.com, and the
    other 3 domains are redirected to it. I have set up a folder for each site
    on bizcomplex.com's server. The actual URL for a file would be like www
    ..bizcomplex.com/restaurant/menu.html.

    I have written a brief domain sniffer script in ASP that will detect if
    someone types in "www. restaurant.com" and automatically move them to the
    "restaurant/" folder. However, I can not see how to allow direct linking if
    someone types in a complete URL, such as "www. restaurant.com/menu.html"

    Any assistance you can provide would be appreciated.

    Thank you.
    Paul
    Paul, Apr 18, 2005
    #1
    1. Advertising

  2. Paul

    Evertjan. Guest

    Paul wrote on 18 apr 2005 in microsoft.public.inetserver.asp.general:

    > I have written a brief domain sniffer script in ASP that will detect
    > if someone types in "www. restaurant.com" and automatically move them
    > to the "restaurant/" folder. However, I can not see how to allow
    > direct linking if someone types in a complete URL, such as "www.
    > restaurant.com/menu.html"
    >


    Make the below include in the top of all asp files.
    other files [img etc] must be pointed to absolutely.

    <%
    snm = lcase(Request.ServerVariables("SERVER_NAME"))
    scn = Request.ServerVariables("SCRIPT_NAME")
    ' allows www. and non www.

    if instr(snm ,"restaurant.com")>0 Then
    if instr(scn ,"/restaurant")=1 then
    response.Redirect scn
    end if
    Response.Redirect "/restaurant" & scn
    elseif instr(snm ,"hotel.com")>0 Then
    if instr(scn ,"/hotel")=1 then
    response.Redirect scn
    end if
    Response.Redirect "/hotel" & scn
    else
    ' this file main domain
    end if
    %>

    not tested

    further you could test in a custom /404.asp
    for files without "/restaurant" or "/hotel"
    and redirect them with it.

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
    Evertjan., Apr 18, 2005
    #2
    1. Advertising

  3. Paul

    Paul Guest

    Thank you for the sample code. I'll work with that and see what I can do.

    Paul
    "Evertjan." <> wrote in message
    news:Xns963CCC4353F74eejj99@194.109.133.29...
    > Paul wrote on 18 apr 2005 in microsoft.public.inetserver.asp.general:
    >
    >> I have written a brief domain sniffer script in ASP that will detect
    >> if someone types in "www. restaurant.com" and automatically move them
    >> to the "restaurant/" folder. However, I can not see how to allow
    >> direct linking if someone types in a complete URL, such as "www.
    >> restaurant.com/menu.html"
    >>

    >
    > Make the below include in the top of all asp files.
    > other files [img etc] must be pointed to absolutely.
    >
    > <%
    > snm = lcase(Request.ServerVariables("SERVER_NAME"))
    > scn = Request.ServerVariables("SCRIPT_NAME")
    > ' allows www. and non www.
    >
    > if instr(snm ,"restaurant.com")>0 Then
    > if instr(scn ,"/restaurant")=1 then
    > response.Redirect scn
    > end if
    > Response.Redirect "/restaurant" & scn
    > elseif instr(snm ,"hotel.com")>0 Then
    > if instr(scn ,"/hotel")=1 then
    > response.Redirect scn
    > end if
    > Response.Redirect "/hotel" & scn
    > else
    > ' this file main domain
    > end if
    > %>
    >
    > not tested
    >
    > further you could test in a custom /404.asp
    > for files without "/restaurant" or "/hotel"
    > and redirect them with it.
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Replace all crosses with dots in my emailaddress)
    >
    Paul, Apr 21, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev
    Replies:
    3
    Views:
    16,092
    Gandalf
    Feb 8, 2004
  2. Joe Fallon
    Replies:
    3
    Views:
    751
    =?Utf-8?B?Z3V5?=
    Jul 16, 2004
  3. ben
    Replies:
    3
    Views:
    502
    Kevin Spencer
    Nov 15, 2004
  4. tshad
    Replies:
    11
    Views:
    805
    tshad
    May 27, 2005
  5. Imran Aziz
    Replies:
    1
    Views:
    527
    Stefan
    Aug 22, 2005
Loading...

Share This Page