Forum Discussion
Cody_Conklin_17
Nimbostratus
Jul 29, 2005Simple HTTPS redirect
I have an HTTPS Virtual Server that is terminating SSL. I would also like to take the inbound https requests and append a specific webpage to it. For example, if the user sends a request to https://...
Jul 29, 2005
Yeah, that will cause an infinite loop as each request will have the host example.mycompany.com and it will match the if every time. You'll want to put an additional check in there that you'll guaranteed won't get called consecutively.
I'm assuming that you will want to redirect to the login_page only if there is no uri specified.
BTW, in your first post you were puting the entire "url" in comparison with the "uri". The "uri" is the trailing path behind the hostname starting with a slashURL = http://example.mycompany.com/login_page
HTTP::host = example.mycompany.com
HTTP::uri = /login_page
This should get you going:
when HTTP_REQUEST {
if { [HTTP::host] equals "example.mycompany.com" } {
if { [HTTP::uri] equals "" or [HTTP::uri] equals "/" } {
HTTP::redirect https://example.mycompany.com/login_page
}
}
}If you don't want to do a full redirect, you can always use the "HTTP::uri" command to change the uri. This won't show up on the client's browser but it will direct them to the login_page (this can allow you to "hide" certain paths that you don't want publicly exposed.)
when HTTP_REQUEST {
if { [HTTP::host] equals "example.mycompany.com" } {
if { [HTTP::uri] equals "" or [HTTP::uri] equals "/" } {
HTTP::uri "/login_page"
}
}
}So now the following requests
https://example.mycompany.com
https://example.mycompany.com/
will get redirected (or forwarded) to
https://example.mycompany.com/login_page
-Joe
Help 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
