Forum Discussion

5 Replies

  • Hello

     

    when HTTP_REQUEST {

     

    set uri [string tolower [HTTP::uri]]

     

    if { $uri equals "/abc/Pages/default.aspx" }{

     

    HTTP::redirect https://[HTTP::host]/123/abc/Pages/default.aspx

     

    } elseif { $uri starts_with "/abc/" }{

     

    HTTP::redirect "https://[HTTP::host]/123$uri"

     

    } else {

     

    }

     

    }

     

    I didn't tested it, let me know if it work for you. Regards,

     

  • Optimized version :

    when HTTP_REQUEST {
        set path [HTTP::path]
        if { $path equals "/abc/Pages/default.aspx" }{
            HTTP::redirect https://[HTTP::host]/123/abc/Pages/default.aspx
             alternatively you can use HTTP::respond 302 Location "/123/abc/Pages/default.aspx"
        } elseif { $path starts_with "/abc/" }{
            HTTP::redirect "https://[HTTP::host]/123[HTTP::uri]"
        }
    }
    

    super optimized version 🙂

    when HTTP_REQUEST {
        set path [HTTP::path]
        if { $path starts_with "/abc/" }{
            HTTP::redirect https://[HTTP::host]/123[HTTP::uri]
             alternatively you can use HTTP::respond 302 Location "/123[HTTP::uri]"
        }
    }
    
  • Optimized version :

    when HTTP_REQUEST {
        set path [HTTP::path]
        if { $path equals "/abc/Pages/default.aspx" }{
            HTTP::redirect https://[HTTP::host]/123/abc/Pages/default.aspx
             alternatively you can use HTTP::respond 302 Location "/123/abc/Pages/default.aspx"
        } elseif { $path starts_with "/abc/" }{
            HTTP::redirect "https://[HTTP::host]/123[HTTP::uri]"
        }
    }
    

    super optimized version 🙂

    when HTTP_REQUEST {
        set path [HTTP::path]
        if { $path starts_with "/abc/" }{
            HTTP::redirect https://[HTTP::host]/123[HTTP::uri]
             alternatively you can use HTTP::respond 302 Location "/123[HTTP::uri]"
        }
    }
    
  • Hi, you can use something like this:

     

    when HTTP_REQUEST { if {[string tolower [HTTP::uri]] starts_with "/abc/"}{ HTTP::redirect "https://[HTTP::host]/123[HTTP::uri]" } }

     

  • Thanks to all. I manage to achieve my redirection using this iRule (Working)

     

    when HTTP_REQUEST { if { [HTTP::host] contains "abc.com" } { if {[string tolower [HTTP::uri]] starts_with "/abc" } { set newuripath [string trimleft [HTTP::uri] /] HTTP::redirect "https://[HTTP::host]/123[HTTP::uri]" } } }