Forum Discussion

9 Replies

  • Are you trying to send a redirect to the user or are you trying to rewrite the uri between the LTM and server while maintaining the original URI in the browser?
  • Is it for that exact string? or do you want to add an "X" to a certain part of the URI.

    I would accomplish your example via the following. I'm assuming you want to redirect if 1) the host is "www.xyz.com" and 2) the URI is "/something/howto.html"

    
    when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] eq "www.xyz.com" and [string tolower [HTTP::uri]] eq "/something/howto.html" } {
    HTTP::redirect "http://www.xyz.com/somethingX/howto.html" } }
    
  • Hi,

     

     

    I am also attempting to determine if the source ip is internal, this iRule I was working on fails.

     

     

    when HTTP_REQUEST {

     

    Check if client IP is in the datagroup

     

    if {[matchclass [IP::client_addr] equals $::internal_net]} and

     

    [HTTP::uri] equals {https://au-csg.xyx.com/Citrix/XenApp/}} {HTTP::uri {https://au-csg.xyz.com/Citrix/XenApp1/}

     

    {

     

     

    }

     

    }
  • So far I am up to here, no errors, but does not work.

     

     

    when HTTP_REQUEST {

     

     

    if {[matchclass [IP::client_addr] equals $::internal_net]

     

     

    and [string tolower [HTTP::host]] eq "www.csg.xyz.com"

     

    and [string tolower [HTTP::uri]] eq "/Citrix/XenApp/" }{

     

     

    HTTP::redirect "https://csg.xyz.com/Citrix/XenApp1" }

     

     

    }

     

  • By using "string tolower," you're automatically converting the host and URI to lower case. Since your "eq" statement compares it to "Citrix" and "XenApp" which contain upper case characters, you'll never match.

    Give this a shot.

    
    when HTTP_REQUEST { 
    if {[class match [IP::client_addr] eq internal_net] and [string tolower [HTTP::host]] eq "www.csg.xyz.com" and [string tolower [HTTP::uri]] starts_with "/citrix/xenapp/" } {
    HTTP::redirect "https://csg.xyz.com/citrix/xenapp1/" } }
    

    I used "starts_with" instead of "eq" so we'd redirect people even if their exact uri didn't match...you can also use "contains" here if you like.

    This should redirect internal clients from "http://www.csg.xyz.com/citrix/xenapp/" to "https://csg.xyz.com/citrix/xenapp1/"