Forum Discussion

Emad's avatar
Emad
Icon for Cirrostratus rankCirrostratus
Jun 23, 2014

Rewrite and Mask

Hi, I need to hide specific URI path via IRule.

Actual URL: www.abc.com/myApp/index.php
Required: www.abc.com/index.php

I have wrote an iRule but its replaceing and adding "/myApp/" for every "/"

when HTTP_REQUEST {
    log local0. "Incoming URI = [HTTP::uri]"
    if { [string tolower [HTTP::uri]] equals "/" and ([HTTP::host] eq "abc.com" or [HTTP::host] eq "www.abc.com")} {
        set uri [string map -nocase {"/" "/myApp/"} [HTTP::uri]]
        log local0. "New URI = $uri"
        HTTP::uri $uri
    }
}

2 Replies

  • I have wrote an iRule but its replaceing and adding "/myApp/" for every "/"

     

    i understand only request to root (/) matches the irule condition ([string tolower [HTTP::uri]] equals "/"), doesn't it?

     

    so, can you explain a bit more about the problem?

     

  • Johny,

    Anytime you use "and" or "or" they must only be dealing with true or false comparisons. You must use brackets to ensure this or you will get errors or unexpected results.

    if { [string tolower [HTTP::uri]] equals "/" and ([HTTP::host] eq "abc.com" or [HTTP::host] eq "www.abc.com")} {
    

    Should be...

    if {([string tolower [HTTP::uri]] equals "/") and (([HTTP::host] eq "abc.com") or ([HTTP::host] eq "www.abc.com"))} {