Forum Discussion

nkroon1's avatar
nkroon1
Icon for Cirrus rankCirrus
Aug 16, 2019

iRule Help - Change URL URI

Hello. I've been having issues with this all morning. I've tried a few different variations but none seem to work.

 

I'm attempting to change the uri of a URL. For example,

 

example.com/nav to example.com/help

 

I've tried a few different iRule, for example the one below.

 

when HTTP_REQUEST {

if : [string tolower [HTTP::host]] equals "example.com"} {

set HTTP::uri /help

}

}

 

I tried another attempt to do redirects, but ended up breaking the page, as any link or action you attempted on the page just ended up failing or making the page freak out.

 

Thanks

5 Replies

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus
    when HTTP_REQUEST {
        if { ( [string tolower [HTTP::host]] equals "example.com" ) and (  [string tolower [HTTP::uri]] equals "/nav" )} {
            HTTP::uri /help
        }
    }
  • I tried the above and it didn't work. I tried a few changes to it as well, such as /nav* and that doesn't seem to make a difference. I'm not sure what I might be doing wrong or why it doesn't like it? If it makes a difference, application is ServiceNow

  • Hi nkroon,

    Can you try these iRules?

    Modify uri without redirect:

    when HTTP_REQUEST {
    	if { ( [string tolower [HTTP::host]] equals "example.com") or ( [string tolower [HTTP::host]] equals "www.example.com") } {
    		if { [string tolower [HTTP::uri]] equals "/nav" } {
    			HTTP::uri "/help"
    		}
    	}
    }

    Redirect

    when HTTP_REQUEST {
    	if { ( [string tolower [HTTP::host]] equals "example.com") or ( [string tolower [HTTP::host]] equals "www.example.com") } {
    		if { [string tolower [HTTP::uri]] equals "/nav" } {
    			HTTP::redirect "http://www.example.com/help"
    		}
    	}
    }
  • Both of them seemed to work, kinda. The first one created a weird refresh loop. The second one, the redirect, worked correctly however the issue I ran into now is it seems to break SSO. It appears that you have to go to the nav page first to complete SSO sign in, and from there it will redirect you to another URI, however the F5 doesn't seem to pick up on that or see it, as I've tried modifying the irules a bit more to see if I can redirect that portion, but it doesn't seem to see it.