Forum Discussion

Shawn_Diehl_899's avatar
Shawn_Diehl_899
Icon for Nimbostratus rankNimbostratus
Aug 21, 2008

URL Rewrite (should be basic)

Thanks in advance for the help. I should be able to figure this out but being slammed I just cant seem to get it right. I've already scoured the web and DevCentral and cant find an example I can put to use.

 

 

I need to replace any instance of login.aspx with default.aspx in an incoming request. I've figrued out how to catch it when the URL looks something like https://www.mycorp.com/login.aspx but its not working when the URL is something like https://www.mycorp.com/somestring/login.aspx. I figrue I need to use a replace but cant find an example that matches my need.

 

 

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] equals "/login.aspx" } {

 

HTTP::uri "/default.aspx"

 

}

 

}

 

3 Replies

  • I am still trying to get the proper solution and came up with this. Any thoughts??

     

     

     

    when HTTP_REQUEST {

     

    set uri [HTTP::uri]

     

    if { HTTP::uri ends_with [string tolower "login.aspx"] } {

     

    HTTP::uri [string map -nocase {"login.aspx" "default.aspx"} [HTTP::uri]]

     

    }

     

    }

     

  •  
     when HTTP_REQUEST { 
        if { [HTTP::uri] ends_with [string tolower "login.aspx"] } { 
          HTTP::uri [string map -nocase {"login.aspx" "default.aspx"} [HTTP::uri]] 
         } 
     }  
     
  • Shouldn't you do the tolower on the URI, not the hard-coded "login.aspx"?

     
     when HTTP_REQUEST { 
       if { [string tolower [HTTP::uri]] ends_with "login.aspx" } { 
         HTTP::uri [string map -nocase {"login.aspx" "default.aspx"} [HTTP::uri]] 
       } 
     }