Forum Discussion
irule question
I have a HTTPS VIP configured on F5. Looking for iRule
https://f5.com/abc/Pages/default.aspx should redirect to https://f5.com/123/abc/Pages/default.aspx https://f5.com/abc/* should redirect to https://f5.com/123/abc/*
5 Replies
- youssef1
Cumulonimbus
Hello
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { $uri equals "/abc/Pages/default.aspx" }{
HTTP::redirect https://[HTTP::host]/123/abc/Pages/default.aspx
} elseif { $uri starts_with "/abc/" }{
HTTP::redirect "https://[HTTP::host]/123$uri"
} else {
}
}
I didn't tested it, let me know if it work for you. Regards,
Optimized version :
when HTTP_REQUEST { set path [HTTP::path] if { $path equals "/abc/Pages/default.aspx" }{ HTTP::redirect https://[HTTP::host]/123/abc/Pages/default.aspx alternatively you can use HTTP::respond 302 Location "/123/abc/Pages/default.aspx" } elseif { $path starts_with "/abc/" }{ HTTP::redirect "https://[HTTP::host]/123[HTTP::uri]" } }super optimized version 🙂
when HTTP_REQUEST { set path [HTTP::path] if { $path starts_with "/abc/" }{ HTTP::redirect https://[HTTP::host]/123[HTTP::uri] alternatively you can use HTTP::respond 302 Location "/123[HTTP::uri]" } }Optimized version :
when HTTP_REQUEST { set path [HTTP::path] if { $path equals "/abc/Pages/default.aspx" }{ HTTP::redirect https://[HTTP::host]/123/abc/Pages/default.aspx alternatively you can use HTTP::respond 302 Location "/123/abc/Pages/default.aspx" } elseif { $path starts_with "/abc/" }{ HTTP::redirect "https://[HTTP::host]/123[HTTP::uri]" } }super optimized version 🙂
when HTTP_REQUEST { set path [HTTP::path] if { $path starts_with "/abc/" }{ HTTP::redirect https://[HTTP::host]/123[HTTP::uri] alternatively you can use HTTP::respond 302 Location "/123[HTTP::uri]" } }- Richard_Lara_71
Nimbostratus
Hi, you can use something like this:
when HTTP_REQUEST { if {[string tolower [HTTP::uri]] starts_with "/abc/"}{ HTTP::redirect "https://[HTTP::host]/123[HTTP::uri]" } }
- BPRIDE
Nimbostratus
Thanks to all. I manage to achieve my redirection using this iRule (Working)
when HTTP_REQUEST { if { [HTTP::host] contains "abc.com" } { if {[string tolower [HTTP::uri]] starts_with "/abc" } { set newuripath [string trimleft [HTTP::uri] /] HTTP::redirect "https://[HTTP::host]/123[HTTP::uri]" } } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com