Forum Discussion
anuj_2931
Nimbostratus
Jun 07, 2012HTTP::host to match all subdomains of a domain
Guys,
I want to write an Irule to redirect http to https for all subdomains in a particular domain. I want to do this because we host many domains on that VS and only one of the domains will have encrypted communication. The VS I will redirect the https traffic to, will serve *.domain.com certificate.
In short when http request comes on VS 1 port 80, I want to check if the http::host is subdomain of domain.com, if yes, I want to redirect it to https to VS 2 which has the right certificate.
Thanks
4 Replies
- t-roy
Nimbostratus
think you want something like:
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] contains ".domain.com"}{
HTTP::redirect "https://x.domain.com[HTTP::uri]"
}
} - anuj_2931
Nimbostratus
I can try this :)
Thanks - hoolio
Cirrostratus
Here's another option that redirects any subdomain for example.com and preserves the requested host and URI in the redirect:when HTTP_REQUEST { if {[string tolower [HTTP::host]] ends_with ".example.com"}{ HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }
Aaron - anuj_2931
Nimbostratus
Thanks Aaron
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