select redirect not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fran7
    New Member
    • Jul 2006
    • 229

    select redirect not working

    Hi, I have this select redirect that doesnt work, only the case else works, anyone see whats wrong with it? Its basically to redirect my dynamic pages to their new homes.
    Any help appreciated.
    Thanks
    Richard


    Code:
    <%@Language=VBScript%> 
    
    <% 
    SiteNameURL = Request.ServerVariables("SERVER_NAME") 
    %> 
    
    <% 
    Select Case SiteNameURL 
    
    Case "http://www.mysite.com/directory.asp?categoryid=1" 
    response.redirect "am-art.asp" 
    
    Case "http://www.mysite.com/directory.asp?categoryid=2" 
    response.redirect "uf-art.asp" 
    
    Case "http://www.mysite.com/directory.asp?categoryid=3" 
    response.redirect "uf-art.asp" 
    
    Case "http://www.mysite.com/directory.asp?categoryid=4" 
    response.redirect "uf-art.asp" 
    
    Case "http://www.mysite.com/directory.asp?categoryid=5" 
    response.redirect "uf-art.asp" 
    
    Case "http://www.mysite.com/directory.asp?categoryid=6" 
    response.redirect "uf-art.asp" 
    
    Case Else 'redirecting everything other than cases selected above 
    
    response.redirect "./" 
    
    End Select 
    
    %>
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Richard,

    If only your Case Else is being hit then none of your other conditions are being met. I'd comment out the redirect and response.write the value of SiteNameURL to the screen so you can see whether it looks as you'd expect.

    Also, as the only difference between the urls is the value of the querystring variable categoryid would it not make sense to test for that rather than the whole address? e.g.

    Code:
    <%
    Dim iCategoryID
    iCategoryID = Request.Querystring("categoryid")
    
    Select Case iCategoryID
        Case 1
         'Redirect 1
        Case 2
         'Redirect 2
    etc
    End Select
    %>
    Let me know if this helps,

    Dr B

    Comment

    • fran7
      New Member
      • Jul 2006
      • 229

      #3
      Thanks Dr B, worked perfectly. Basically this for anyone interested is a dynamic redirect that works fine.


      Code:
      <%@Language=VBScript%> 
      
      <% 
      Dim iCategoryID 
      iCategoryID = Request.Querystring("categoryid") 
      Select Case iCategoryID 
      case "1" 
      Response.Status="301 Moved Permanently"
      Response.AddHeader "Location","newaddress.asp"
      case "2" 
      Response.Status="301 Moved Permanently"
      Response.AddHeader "Location","newaddress.asp"
      case "3" 
      Response.Status="301 Moved Permanently"
      Response.AddHeader "Location","newaddress.asp"
      case "4" 
      Response.Status="301 Moved Permanently"
      Response.AddHeader "Location","newaddress.asp"
      case "62" 
      Response.Status="301 Moved Permanently"
      Response.AddHeader "Location","newaddress.asp"
      case "5" 
      Response.Status="301 Moved Permanently"
      Response.AddHeader "Location","newaddress.asp"
      case "55" 
      Response.Status="301 Moved Permanently"
      Response.AddHeader "Location","newaddress.asp"
      
      Case Else 'redirecting everything other than cases selected above 
      
      response.redirect "./" 
      
      End Select 
      %>

      Comment

      Working...