Forum Discussion

Boris_11323's avatar
Boris_11323
Icon for Nimbostratus rankNimbostratus
Jan 25, 2018

Redirect by last directory as parameter.

Hi, I need to redirect from [dynamic directory name] to [dynamic directory name] Thanks for help.

 

2 Replies

  • Hello Thiyagu,

    So, You can try with following Irule:

    when HTTP_REQUEST {
    set uri [HTTP::uri]
    
    if { $uri starts_with "/a/"}{
        set rangeuri [string range [HTTP::uri] 3 end]
        set redirecturi "/b/go?p=$rangeuri"
        HTTP::redirect "$redirecturi"
        log local0. "redirect to $redirecturi from $uri"
    
    }
    }
    

    Regards,

  • Hi,

     

    you can try this code.

     

    when HTTP_REQUEST {
        if {[scan [HTTP::uri] "/a/%s" dirname] == 1} {
            HTTP::redirect  "http://www.site2.com/b/go?p=[URI::encode $dirname]"
        }
    }