Forum Discussion

Suresh_Jo_32729's avatar
Suresh_Jo_32729
Icon for Nimbostratus rankNimbostratus
Apr 04, 2018

Need to create one irule to rediect uri abc.ra.well.com/portallogon(not actual uri) to the same uri with extention /irj/portal

I need to create one irule to rediect uri abc.ra.well.com/portallogon(not actual uri) to the same uri with extention /irj/portal. As of now I have to test it via one server and after successfully testing 47 more servers will be added. I can't add this server in my pool( which is called in the VIP), so I think I need to create datagroup list for that server. I was trying to create one irule, below is the rule which I created as of noe.

when HTTP_REQUEST { check if this host is in the main datagroup if { [HTTP::host] equals "abc.ra.well.com/portallogon" and [HTTP::uri] equals "/" } { set newuri "/irj/portal" HTTP::uri "$newuri" set newurl [class match -value [string tolower [HTTP::host]] equals redirect_datagroup]

 if the host is not found in the main datagroup, check the secondary datagroup
if {$newurl eq ""}
{
     check if this host is in the secondary datagroup that requires uri be included
    set newurl2 [class match -value [string tolower [HTTP::host]] equals redirect_datagroup2]

Can someone please help me to setup this irule.

2 Replies

  • when HTTP_REQUEST { check if this host is in the main datagroup if { [HTTP::host] equals "abc.ra.well.com/portallogon" and [HTTP::uri] equals "/" } { set newuri "/irj/portal" HTTP::uri "$newuri" set newurl [class match -value [string tolower [HTTP::host]] equals redirect_datagroup]

     if the host is not found in the main datagroup, check the secondary datagroup
    if {$newurl eq ""}
    {
         check if this host is in the secondary datagroup that requires uri be included
        set newurl2 [class match -value [string tolower [HTTP::host]] equals redirect_datagroup2]
    
        Sending again..
    
  • Hello,

    Firstof be carreful do not mix up hostname, URI and URL

    URL: abc.ra.well.com/portallogon
    URI: /portallogon
    hostname: abc.ra.well.com
    
    
    when HTTP_REQUEST { 
    
    set host [string tolower [HTTP::host]]
    set uri [HTTP::uri]
    
    if { [class match $host equals "host_datagroup"] and $uri equals "/" } {
        set newuri [class match -value $host] equals host_datagroup]
        HTTP::redirect "$newuri"
        return
    }
    
    }
    

    In your datagroup you will have something like that:

    string: abc.ra.well.com

    Value: /irj/portal

    If user access with the following URL: https://abc.ra.well.com/ it will be redirect to https://abc.ra.well.com/irj/portal

    I hope that's what you wanted. I did not test the irule. if you need other things light your need Regards.