Forum Discussion

JEHRS_288007's avatar
JEHRS_288007
Icon for Nimbostratus rankNimbostratus
Oct 19, 2016

Removing /string/ from URL

Hello,

 

I would like create a iRule which removes only a /string/ from a URL and this is given to a pool of tomcat servers. Which practice would have the less impact on the performance?

 

Thanks!

 

1 Reply

  • Try something like this..

    Option 1

    If you want to redirect to new URI from client browser, try below irule. When using this, client would be able see the new url (after removing /string). [URI Redirect method]

    when HTTP_REQUEST {
        if {[string tolower [HTTP::uri]] starts_with "/string"}{
            set newuri [string map -nocase {"/string" ""}[HTTP::uri]]
            HTTP::redirect "http://[HTTP::Host]$newuri"
            }
        }
    

    Option 2

    If you dont want client to see the new url, try below irule. On the client browser it won't make any changes but the backend it will remove /string. [URI Rewrite method]

    `when HTTP_REQUEST {
        if {[string tolower [HTTP::uri]] starts_with "/string"}{
            set newuri [string map -nocase {"/string" ""}[HTTP::uri]]
            HTTP::uri $newuri
            }
        }
    
    
    -Jinshu