Forum Discussion
Url redirection
The iRule posted by should work, but you can clean it up a bit. Here we do the following:- More efficient string comparison using starts_with rather than contains. Also, more secure as a URL may be odd and repeat that string as part of URI path (unlikely though).
- Removed unnecessary comparison for host header. Likely there is no virtual hosting, so all (and only) example.com traffic hitting the virtual server. We only need it for return if path doesn't match our pattern.
- Support both https and http protocols. In case you perform or what to add SSL termination or what not.
- You could also get fancier and support multiple paths you want to check via data groups, or even use a variable for the comparison string portion
So here we have it.
when HTTP_REQUEST {
if { [string tolower [HTTP::path]] starts_with "/apps/test" }{
return
} else {
if { [TCP::local_port] == 443 }{
HTTP::redirect "https://[HTTP::host]"
} else {
HTTP::redirect "http://[HTTP::host]"
}
}
}
Sorry for the formatting, but posting TCL code via the iPhone triggers an error on DevCentral!
"Correct the highlighted errors and try again.
Post flooding detected (community received posts of a unique message more than 1 times within 3,600 seconds)"
Thats even with just a simple "test" using the TCL </> option in the WYSIWYG editor. Strange.
- Leslie_HubertusJun 13, 2023Ret. Employee
Tagging LiefZimmerman so he can see your issue with sharing TCL code from your phone triggering a post flooding timeout.
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