Forum Discussion

Beau_Monday_107's avatar
Beau_Monday_107
Icon for Nimbostratus rankNimbostratus
Sep 29, 2005

redirect to a specific page, but keep the Querystring?

Hi,

 

 

I have a client that wants to direct users arriving via a specific host to a special login page. This is fine, I have this working. However, because I redirect to a specific URI, I lose anything the user might have in the querystring.

 

 

Is there a way to tell the BigIP that it should tack on any querystring to the page I am redirecting the user to?

 

 

Here is my rule as it stands:

 

 

if (http_host == "partnertraining.host.com") {

 

redirect to "https://education.host.com/application/Custom_Login.asp"

 

}

 

 

This works fine, but I lose the querystring, if there was one.

 

 

Thanks in advance

 

bmonday
  • Thanks for the help Colin. Yeah, I'm interested in passing along the querystring, if one exists. I tried your suggestion, but I am getting a syntax error:

     

     

    Error 331835 -- Rule string to tree failed. - syntax error at '+'

     

    line 6: redirect to "https://host.domain.com/application/custom_Login.asp?" + findstr(http_uri, "?", 1)

     

     

    I am running ver 4.2PTF-09 Build 34. Is the syntax different under that old build?

     

     

    Thanks

     

    bmonday
  • Martin_Machacek's avatar
    Martin_Machacek
    Historic F5 Account
    Yes, the syntax is different in 4.2, the string composition using '+' is not available. In version 4.2 you can use the %u expansion in the redirect string to get the original URI, but there is no way to get just the query variables. It means that the server needs to accept the extra component in the URI. Your rule may look like this:

    
    if (http_host == "partnertraining.host.com") {
        redirect to "https://education.host.com/application/%u"
    }

    Please, refer to section "Using format strings (expansion characters)"

    of the BIG-IP Reference Guide for details (http://tech.f5.com/home/bigip/manuals/bigip4_5_10/bigip4_5_10ref/BIGip_pools.html1184371).

    So, if for example the original request is:

    
    http://partnertraining.host.com/login.asp

    The redirect will be to:

    
    https://education.host.com/application/login.asp

    You'll need to use URL rewritting of some sort (for example mod_rewrite in Apache) at the target server to do the rest. You can always upgrade to a more up to date version of BIG-IP and use string parsing and composition to construct the redirect to URL :-).