Forum Discussion

msaud's avatar
msaud
Icon for Cirrus rankCirrus
Sep 12, 2024

URL redirection

Please help, Need to create iRule:

 

 

https://tableau-snd.ucsf.edu/#/site/QA/views/ProjectChartfieldSearch/ProjectChartfieldSearch

/#/site/QA/ : will be same 

ProjectChartfieldSearch/ProjectChartfieldSearch : Can be anything

redirect to :
https://tableauqa.ucsf.edu/#/site/QA/views/ProjectChartfieldSearch/ProjectChartfieldSearch

 

  • Hi,

    F5 iRules usually don’t handle the part after the # in URLs because that part isn't sent to the server. Normally, the iRule below should work for redirection, but the fragment (#) issue might prevent it from functioning as expected:

    when HTTP_REQUEST {

        if { [HTTP::host] eq "tableau-snd.ucsf.edu" && [HTTP::uri] starts_with "/#/site/QA/" } {

            log local0. "Redirecting request: Host - [HTTP::host], URI - [HTTP::uri]"

            set new_uri "https://tableauqa.ucsf.edu[HTTP::uri]"

            HTTP::redirect $new_uri
        } else {
            # Log the request that does not match the condition
            log local0. "No redirection: Host - [HTTP::host], URI - [HTTP::uri]"
        }
    }

    This iRule is meant to redirect requests based on the URI. However, since the fragment part (#) isn’t sent to the server, this approach might not work as intended.

    To check if the fragment part is being processed, you can use this simple iRule:

    when HTTP_REQUEST {
        set uri [HTTP::uri]
        log local0. "URI: $uri"
    }

    This iRule will log the URI of incoming requests. You can use it to see if the fragment is included in the URI and determine if it's being processed or not.

    Hope this helps.