Redirect 302 with aFlex

rodrigoshrodrigosh Member

Hello, I need your help and knowledge on A10 with aFlex.

I am trying to create a 302 redirect for a site that is published on the internet but when testing the redirect it does not execute it, this is my code so that you can guide me:

when HTTP_REQUEST {

     if {[HTTP::host] == "https://recargaweb.imperial.com/" } {

          HTTP::respond 302 Location "https://recargaweb.imperial.com/publico"

   }

}

Tagged:

Comments

  • invia_itopsinvia_itops Member

    Host does not contain the protocol or /, just using recargaweb.imperial.com should work.

  • boteyeboteye Member
    edited June 2022

    Please try below:

    when HTTP_REQUEST {

    if { [HTTP::host] equals "recargaweb.imperial.com" } {

    HTTP::redirect "https://[HTTP::host]/publico" 

    }

    I have tested this script and the results are as below


  • rodrigoshrodrigosh Member

    Apparently I must remove HTTPS from the host, although the ACOS system does not claim me for entering that protocol.

    It worked for me this way:

    when HTTP_REQUEST {

    if {[HTTP::host] matches "recargaweb.imperial.com" and [HTTP::uri] matches "/"} {

    # [HTTP::host] "recargaweb.imperial.com"

    HTTP::uri /publico

    }

    }

    Anyway, I'm going to try the possibilities that were indicated to me... thank you very much

  • invia_itopsinvia_itops Member

    You can also just use HTTP Policy instead, no need for an aflex in this case.

  • rodrigoshrodrigosh Member

    If you tried to redirect with an HTTP policy, but the site did not load, it indicated that it has been redirected many times in the browser.

  • boteyeboteye Member

    The expression for the "If" statement you mentioned is accurate. [HTTP::uri] equals "/" is required to avoid going into an infinite loop.

Sign In or Register to comment.