Forum Discussion
Walter_WorkAcct
Altostratus
Apr 24, 2021iRule with multiple 301 redirects only redirecting main URI
I am new to the F5 and working on an irule to 301 permanently redirect traffic from links to our old site to new locations on the new site. The issue is that only the default portion of the code is w...
Walter_WorkAcct
Altostratus
Apr 24, 2021Enes Afsin Al, thank you for the response and I do appreciate it but even changing that comparison only works on the default. For example, oldsite.ournewsite.net/foo goes to https://ournewsite.net/oldsitestuff instead of https://ournewsite.net/oldsitestuff/foo
Apr 24, 2021
when HTTP_REQUEST {
log local0. "oldsitelog1 | host = [HTTP::host] | uri = [HTTP::uri] | client_ip = [IP::client_addr]"
if { [HTTP::host] equals "oldsite.ournewsite.net" } {
switch -glob [HTTP::uri] {
"*/foo" {
log local0. "oldsitelog2 foo | uri = [HTTP::uri] | client_ip = [IP::client_addr]"
HTTP::respond 301 Location https://ournewsite.net/oldsitestuff/foo
return
}
"*/bar" {
log local0. "oldsitelog3 bar | uri = [HTTP::uri] | client_ip = [IP::client_addr]"
HTTP::respond 301 Location https://ournewsite.net/oldsitestuff/bar
return
}
default {
log local0. "oldsitelog4 default | uri = [HTTP::uri] | client_ip = [IP::client_addr]"
HTTP::respond 301 Location https://ournewsite.net/oldsitestuff
return
}
}
}
}Can you investigate ltm logs?
tail -f /var/log/ltm | grep oldsitelogHelp guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
