determine and set directory

Last post 05-28-2008 1:16 PM by jchandra. 8 replies.

Sort Posts:

  • determine and set directory

    05-16-2008, 11:13 PM
    • Loading...
    • tommi
    • Joined on 01-02-2006, 3:59 AM
    • Posts 19

    I have a server where I am running several domains, so I redirect to folder for each.  How can I determine and set the directory? 

    For example, I use a VBscript asp file to redirect to the folder for webs based on domain:

    Select Case SiteNameURL

    Case "www.domain1.com"

    Response.Redirect "web1\index1.aspx"

    Case "www.domain2.com"

    Response.Redirect "web2\index2.aspx"

    end select

    The redirect, however, doesn't retain the path, so the next click has a path error.

    How can I insure the right path?

  • Re: determine and set directory

    05-17-2008, 12:49 AM
    • Loading...
    • devcalpoly
    • Joined on 10-08-2007, 10:03 PM
    • Southern California
    • Posts 212

    The following works great in classic ASP, haven't tested w/ .NET (Gut feeling that it should work fine) 

    // Assign SiteNameURL to Server variable

    SiteNameURL = request.servervariables("HTTP_HOST")
    SELECT CASE SiteNameURL
    CASE "www.domain1.com" Response.Redirect "web1\index1.aspx"
    CASE "www.domain2.com" Response.Redirect "web2\index.aspx"
    END SELECT 
     
    Dev
  • Re: determine and set directory

    05-17-2008, 12:52 AM
    • Loading...
    • jchandra
    • Joined on 05-15-2008, 5:36 AM
    • Jakarta, Indonesia
    • Posts 197

    Well, one way is to make sure all your pages only do relative linking. link like /Web1/blah.aspx is strictly forbidden, use blah.aspx instead.

    A second way is to employ a routing engine in the ISAPI layer or HttpHandler / Module layer. 

    Jimmy Chandra
    Blogging at Incoherent Rambling

    Mark this post as Answer if you think it helped you solve the problem.

  • Re: determine and set directory

    05-17-2008, 6:47 AM

     

    SiteNameURL = request.servervariables("HTTP_HOST")
    it will result to domain1.com not www.domain1.com
    so check the condition according to that  
     
    ======================================
    Regard,
    Pradeep Sahoo
    Sr. Sofware Developer
    Don't forget to click "Mark as Answer" on the post that helped you.
  • Re: determine and set directory

    05-17-2008, 6:55 AM

    Arent you using wrong path?

    It should be Response.Redirect "web1/index1.aspx" insted of Response.Redirect "web1\index1.aspx"

    Note the change of "/". URL accepts "/" and not "\". It doesnot matter you work in Windows or linux platform.

  • Re: determine and set directory

    05-17-2008, 2:51 PM
    • Loading...
    • tommi
    • Joined on 01-02-2006, 3:59 AM
    • Posts 19

    this is what I'm doing, thanks for validation!

  • Re: determine and set directory

    05-17-2008, 2:57 PM
    • Loading...
    • tommi
    • Joined on 01-02-2006, 3:59 AM
    • Posts 19

    after I do response.redirect, I only route with next.aspx, not web1\next.aspx

    so, say path for routing is "http://domain.com/index.asp"  this page just does redirect per script, such as "web1\index.aspx" 

    the problem is, it's not retaining the web1 folder as part of the path for the next click, so it's trying to access http://domain.com/index.aspx not http://domain.com/web1/index.aspx

     

  • Re: determine and set directory

    05-17-2008, 2:58 PM
    • Loading...
    • tommi
    • Joined on 01-02-2006, 3:59 AM
    • Posts 19

    it's loading the first page, so the redirect is working.  we are not at the URL level, it's in a VBscript, thanks.

  • Re: determine and set directory

    05-28-2008, 1:16 PM
    • Loading...
    • jchandra
    • Joined on 05-15-2008, 5:36 AM
    • Jakarta, Indonesia
    • Posts 197

     Try take a look at this blog entry from ScottGu

    http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

     

    Jimmy Chandra
    Blogging at Incoherent Rambling

    Mark this post as Answer if you think it helped you solve the problem.

Page 1 of 1 (9 items)