07-Jun-2023 07:35
Hi guys I need your need.
Let's say I have a url (example.com/apps/test.)
I want this exact url to work, and anything else that's not that url to redirect to (example.com)
07-Jun-2023 07:55
Hi @mj16othman ,
Try this :
when HTTP_REQUEST {
if { [string tolower "[HTTP::host][HTTP::path]"] contains "example.com/apps/test" }{
return
} else {
#HTTP::redirect "http://example.com"
HTTP::redirect "http://[HTTP::host]"
}
}
> you must assign the default pool to that virtual server.
use only one of those redirections :
HTTP::redirect "http://example.com"
HTTP::redirect "http://[HTTP::host]"
I hope this helps you
07-Jun-2023 20:10
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]"
}
}
}
07-Jun-2023 20:13
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.
12-Jun-2023 17:29
Tagging @LiefZimmerman so he can see your issue with sharing TCL code from your phone triggering a post flooding timeout.
08-Jun-2023 01:50
Hi @whisperer ,
Thanks a lot ,
I have tested it in my internal Lab , it worked as expected for HTTP only however he can do the same for HTTPS but with offloading and redirecting to https at least.
@mj16othman
08-Jun-2023 04:29
@Mohamed_Ahmed_Kansoh Correct, for HTTPS you would need to have an appropriate VS with client SSL profile and listening on standard port 443. I always think about writing generic iRules so you can resume them for multiple applications.
08-Jun-2023 05:48
@whisperer ,
I got you , well I like this way to normalize everything to be generic 😉