Forum Discussion

Sean_M__85845's avatar
Sean_M__85845
Icon for Nimbostratus rankNimbostratus
Dec 14, 2011

Performing a Redirect with URL Variables

I am trying to create an iRule that will perform a redirect using information within the original URL and creating a redirect with that information. Here's and example of what it would look like:

 

 

Original URL's:

 

http://www.abc.com/directorya/llisapi.dll/?nodeid=67770153&vernum=1

 

 

OR

 

 

http://www.abc.com/directorya/llisapi.dll/?objid=67770153&objaction=open&viewtype=1

 

 

New URL:

 

http://www.xyz.com/Pages/MigrationID.aspx?migrationID=67770153

 

 

Basically I need to look for either the "nodeid" or "objid" in the original URL and use that same ID in the new URL as the "migrationID". Any suggestions on what the iRule would look like?

3 Replies

  • Hi Sean,

     

     

    You can parse the value of nodeid, objid or any other URI parameter using [URI::query [HTTP::uri] $parameter_name]:

     

     

    http://devcentral.f5.com/wiki/iRules.URI__query.ashx

     

     

    Are there specific URIs you want to check for redirecting? If so you can use a switch statement to check the URI:

     

     

    http://devcentral.f5.com/wiki/iRules.switch.ashx

     

     

    Aaron
  • Hi Sean M.

    Sure, you can do that using URI::query and specifying the parameter.

    Here is an example:

    
    when HTTP_REQUEST {
    if { [HTTP::uri] contains "nodeid" } {
    HTTP::redirect "http://www.xyz.com/Pages/MigrationID.aspx?migrationID=[URI::query [HTTP::uri] nodeid]"
    }
    if { [HTTP::uri] contains "objid" } {
    HTTP::redirect "http://www.xyz.com/Pages/MigrationID.aspx?migrationID=[URI::query [HTTP::uri] objid]"
    }
    }
    

    Hope this helps.
  • Michael-

     

    Your example worked perfectly! Thanks for the assitance guys - I really apprecitate the help!