Forum Discussion
Miron_du_Plessi
Nimbostratus
Nov 03, 2007HTTP Redirect based on URI
Hi,
I have a webserver behind our LTM. Access to the webserver is working correctly when users use the full url of
https://remedy.xxx.net/arsys/home
however we are trying to ensure that they reach the correct webpage even if they type.
https://remedy or
https://remedy.xxx.net
However when they type this they are directed to the default apache page.
To do this on the load balancer instead of the webserver I thought that the following irules should solve the problem.
However it appears to have no effect, and im thinking that the problem may lie with the if statements. I did try and test if the redirect will work without the if statements which appeared to work obviously with errors as expected.
****************************************************
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri ends_with "/remedy" } {
HTTP::redirect "https://remedy.xxx.net/arsys/home"
} elseif { $uri ends_with "/remedy.xxx.net" } {
HTTP::redirect "https://remedy.xxx.net/arsys/home"
}
}
****************************************************
when HTTP_REQUEST {
if { [HTTP::uri] ends_with "/remedy"} {
HTTP::redirect "https://remedy.xxx.net/arsys/home"
} elseif { [HTTP::uri] ends_with "/remedy.xxx.net"} {
HTTP::redirect "https://remedy.xxx.net/arsys/home"
}
}
I know there are a few topics already on this subject, which seem to suggest that it is quite easy.
Any ideas.
Regards
Miron
- hoolio
Cirrostratus
Hi Miron,when HTTP_REQUEST { log local0. "URI: [HTTP::uri]" if { $uri ends_with "/remedy" } { log local0. "URI: [HTTP::uri] matched /remedy check" HTTP::redirect "https://remedy.xxx.net/arsys/home" } elseif { $uri ends_with "/remedy.xxx.net" } { log local0. "URI: [HTTP::uri] matched /remedy.xxx.net check" HTTP::redirect "https://remedy.xxx.net/arsys/home" } }
when HTTP_REQUEST { log local0. "Host: [HTTP::host], URI: [HTTP::uri]" if { [string tolower [HTTP::host]] eq "remedy"} { log local0. "Host: [HTTP::host] matched remedy check" HTTP::redirect "https://remedy.xxx.net/arsys/home" } elseif { [string tolower [HTTP::host]] eq "remedy.xxx.net" } { log local0. "Host: [HTTP::host] matched remedy.xxx.net check" HTTP::redirect "https://remedy.xxx.net/arsys/home" } }
when HTTP_REQUEST { log local0. "Host: [HTTP::host], URI: [HTTP::uri]" if { not ([string tolower [HTTP::host]] eq "remedy.xxx.net")} { log local0. "Host: [HTTP::host] didn't match remedy.xxx.net; redirecting." HTTP::redirect "https://remedy.xxx.net/arsys/home" } }
- Miron_du_Plessi
Nimbostratus
Aaron , - Miron_du_Plessi
Nimbostratus
Aaron, - Regarding the null...
- Miron_du_Plessi
Nimbostratus
Joe/Aaron, - hoolio
Cirrostratus
If the client makes a request to the VIP address over HTTPS with a host header value that doesn't match the cert's CN, they'll get the browser prompt to accept the mismatched cert. There isn't anything you can do to eliminate that. - Miron_du_Plessi
Nimbostratus
Aaron, - hoolio
Cirrostratus
The second redirect should work:when HTTP_Request{ HTTP::redirect "https://remedy.xxx.net/arsys/home" }
- Miron_du_Plessi
Nimbostratus
Aaron, - Jo_Anglin_5148Historic F5 AccountMiron,
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