For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Shivam_84461's avatar
Shivam_84461
Icon for Nimbostratus rankNimbostratus
May 21, 2015

Problem with URL redirection

I wanted to redirect the webpages on this condition

if http://xyz.com/j/k/l redirect to www.abc.com

if http://xyz.com redirect to https://xyz.com/a/b

When I configured the irule, first part is working but not the second one. So basically when we try accessing http://xyz.com its creating a redirect loop.

My irule

when HTTP_REQUEST { if { [HTTP::uri] == "/j/k/l" } { HTTP::redirect "https://www.abc.com/" }

elseif { [HTTP::uri] == "/"  } {
    HTTP::redirect "https://xyz.com/a/b"    
}
else {
    HTTP::redirect "https://[HTTP::host][HTTP::uri]"    
}

}

Thanks Shivam

11 Replies

  • This is working

     

    on my VS for https

     

    when HTTP_REQUEST { if { [HTTP::uri] matches_regex {.ghjk.do} } { HTTP::redirect "" } if { [ string tolower [HTTP::uri]] equals"/" } { HTTP::redirect "" } if { [TCP::local_port] != 443 } { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }

     

    On my VS for port 80

     

    when HTTP_REQUEST { if {[TCP::local_port] != "443"} { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } else { if { [HTTP::host] matches_regex {.ghjk.do}} { HTTP::redirect "" } elseif { [HTTP::uri] == "/"} { HTTP::redirect "" } } }

     

    Thanks for your help Michael