Forum Discussion

sudarshan_cheru's avatar
sudarshan_cheru
Icon for Altostratus rankAltostratus
Jun 06, 2016

irule to use redirection to another url with login credentials generated from the header

My requirement is to redirect the url to other url with copied credential part generated in the browser header too. when user hits https://www.abc.com/acspl/cgsContribInit?AI=9d8278d298e24f1fb9477b602fc586fe&ccsource=LK529NH AI=9d8278d298e24f1fb9477b602fc586fe&ccsource=LK529NH this is credential part i guess and it varies. so now he has to redirect to https://www.123.com/prgw/dpcs/myfriend/mlgLandingPage?uuid=9d8278d298e24f1fb9477b602fc586fe&ccsource=LK529NH

 

that means redirection with copying credential part 9d8278d298e24f1fb9477b602fc586fe&ccsource=LK529NH too.

 

5 Replies

  • Hi,

    try to use the following as example :

     

    when HTTP_REQUEST {
        if { [HTTP::header Host] eq "www.abc.com" and [HTTP::path] contains "/acspl/cgsContribInit" and [HTTP::query] contains "AI=" and [HTTP::query] contains "ccsource=" } {
            HTTP::respond 302 noserver "Location" "https://www.123.com/prgw/dpcs/myfriend/mlgLandingPage?uuid=[URI::query [HTTP::uri] AI]&ccsource=[URI::query [HTTP::uri] ccsource]" Cache-Control" "no-cache, must-revalidate"
        }
    }
    

     

    • sudarshan_cheru's avatar
      sudarshan_cheru
      Icon for Altostratus rankAltostratus

      HI Yann, i am very sorry to give you late reply. coming to the point using your irule i am not able to get the credentials path. Rest part i am getting redirected. in the last it showing only uuid=&ccsource=

       

    • Yann_Desmarest's avatar
      Yann_Desmarest
      Icon for Cirrus rankCirrus

      Hi,

      I just updated the source code example.

      The URI was missing in the command to query specific parameters :

       

      [URI::query [HTTP::uri] AI]

       

      Now, it should works fine

      BR

      Yann

       

    • sudarshan_cheru's avatar
      sudarshan_cheru
      Icon for Altostratus rankAltostratus

      Fantastic Yann. It worked . Thanks alot for quick help. Merry Christmas and happy new year.

       

  • Try this (untested):

     

    when HTTP_REQUEST {
        if { ([HTTP::host] eq "www.abc.com") and ([HTTP::query] starts_with "Al=") } {
            HTTP::query [string map {Al= uuid=} [HTTP::query]] 
            HTTP::respond 301 Location "https://www.123.com/prgw/dpcs/myfriend/mlgLandingPage?[HTTP::query]"
        }
    }