Forum Discussion

Daniel_104050's avatar
Daniel_104050
Icon for Nimbostratus rankNimbostratus
Aug 29, 2012

Need more redirect help

Sorry for the elementary questions, but I am new to F5 and have been thrown to the wolves so to speak. I need to find out how/if this can be done and searches aren't showing me what I am looking for, at least I don't think...so here goes

 

 

I need the below redirects to work in 1 irule on one VIP. Is this possible?

 

 

when HTTP_REQUEST {

 

 

if { [HTTP::host] equals "site/a"}{

 

HTTP::redirect "site/sites/a"}

 

}

 

 

if { [HTTP::host] equals "site/b"}{

 

HTTP::redirect "site/sites/b"}

 

}

4 Replies

  • e.g.

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       destination 172.28.19.79:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       if {[HTTP::host] eq "site"} {
          switch [string tolower [HTTP::uri]] {
             "/a" { HTTP::redirect "http://[HTTP::host]/sites/a" }
             "/b" { HTTP::redirect "http://[HTTP::host]/sites/b" }
             default {
                 do something
                 }
          }
            }
    }
    }
    
    [root@ve10:Active] config  curl -I http://172.28.19.79/a -H "Host: site"
    HTTP/1.0 302 Found
    Location: http://site/sites/a
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve10:Active] config  curl -I http://172.28.19.79/b -H "Host: site"
    HTTP/1.0 302 Found
    Location: http://site/sites/b
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    
  • thank you but I am having some problems getting this to work. This is what I have in my irule. When the user hits the site sharepoint goes and retrieves the site from the database. I want to do a re-write, not a redirect I think. This way it actully sends the url string.

     

     

    when HTTP_REQUEST {

     

    if {[HTTP::host] eq "site"} {

     

    switch [string tolower [HTTP::uri]] {

     

    "/a" { HTTP::redirect "http://[HTTP::host]/sites/a" }

     

    "/b" { HTTP::redirect "http://[HTTP::host]/sites/b" }

     

    default {

     

    do something

     

    }

     

    }

     

    }
  • thank you but I am having some problems getting this to work. This is what I have in my irule. When the user hits the site sharepoint goes and retrieves the site from the database. I want to do a re-write, not a redirect I think. This way it actully sends the url string.

     

     

    when HTTP_REQUEST {

     

    if {[HTTP::host] eq "site"} {

     

    switch [string tolower [HTTP::uri]] {

     

    "/a" { HTTP::redirect "http://[HTTP::host]/sites/a" }

     

    "/b" { HTTP::redirect "http://[HTTP::host]/sites/b" }

     

    default {

     

    do something

     

    }

     

    }

     

    }
  • I am unable to get the rule to work. I am not even sure why since it is seemingly such an easy rule