Forum Discussion

Aj2's avatar
Aj2
Icon for Altostratus rankAltostratus
Feb 16, 2023

Need Help for iRule

Need Help to write irule :
Redirects are for HTTP requests made with a path prefix matching https://xyz.test.com/age/signup.
Matching requests should be redirected to https://abc.test.com/#/inSign/invite,
Additionally, a new query parameter should be appended to the resulting URL: account=xyz
The redirected request should include the query parameters supplied from the original request before the redirect.

3 Replies

  • Aj2 This should do exactly what you would like for the hosts and uri paths provided.

    when HTTP_REQUEST priority 500 {
    
        set HOST [HTTP::host]
        set URI [string tolower [HTTP::uri]]
    
        if { ((${HOST} == "xyz.test.com") && (${URI} == "/age/signup")) } {
            HTTP::redirect "https://abc.test.com/#/inSign/invite?account=xyz"
        }
    
    }
    • Awesome Paulius , 

      I will add an info for you , its highly recommended to give up using variables in your Scripts , and use it when you have to use it only. 
      that's for performance concerns.


      • Mike757's avatar
        Mike757
        Icon for MVP rankMVP

        Not sure in this case, Mohamed...

        I get a feeling the example is more general, and variables would be needed. When Aj2 wrote "zyz" I imagine it may take up any value.

        Aj2, can you confirm the need for string replacement in your request? Or did Paulius answer your needs 100%?

        /Mike