Forum Discussion

Almassud_221797's avatar
Aug 29, 2016

Redirect iRule

Hello all,

I have a simple iRule that redirects to another URL:

when HTTP_REQUEST {

HTTP::redirect "http://host.DomainName.com/uri1[HTTP::uri]"

}

problem that I am facing is that there are time when users actually add the /uri1, and then the iRule adds another one, which is a page cannot be displayed.

is there to make the iRule to add /uri only if it's not already there?

thanks in advance MJ

3 Replies

  •    when HTTP_REQUEST {
        if { [ string tolower [HTTP::uri]] starts_with "/uri1" } {
            return
        }
            else {
                HTTP::redirect "http://host.DomainName.com/uri1[HTTP::uri]"
            }
    }
    
  • Blecchh, I hate using negatives in an irule, try this:

    when HTTP_REQUEST {
        if { ! [ string tolower [HTTP::uri]] starts_with "/uri1" } {
            HTTP::redirect "/uri1[HTTP::uri]"
        }
    }
    
  • No dice.

     

    I think my first post is a bit confusing and I apologize for that. so the iRule is this:

     

    when HTTP_REQUEST {

     

    HTTP::redirect "http://host.DomainName.com/uri1[HTTP::uri]" }

     

    The iRule in its current state redirects fine, but the only problem is the with the uri where it gets doubled if it's already there, so what needs to happen is that the iRule needs to check if there's any uri it would strip it before it redirects to the final url/uri.

     

    I hope making sense and not muddying this even further :)