Forum Discussion
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
- Shivam_84461
Nimbostratus
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
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