Forum Discussion
Greg_Bishop_104
Nimbostratus
Jun 27, 2011redirect subdomain to append to uri
Hey guys, I've done a little bit with iRules but not very much. What I'm looking for is to redirect a large number of subdomains such as the following:
greg.domain.com --> www.domain.com/sit...
hoolio
Cirrostratus
Jun 28, 2011Hi Greg,
You can use the string range, getfield or scan command to parse the subdomain from a host header value:
when HTTP_REQUEST {
Check for a non-null length host header
if {[string match {*[a-zA-Z]*} [HTTP::host]]}{
Use string commands to parse the subdomain
set subdomain [string range [HTTP::host] 0 [expr {[string first . [HTTP::host]] -1}]]
Use the getfield command to parse the subdomain
set subdomain [getfield [HTTP::host] . 1]
Use scan to parse the subdomain
scan [HTTP::host] {%[^.]} subdomain
}
}
I'd guess that getfield is probably the simplest and potentially the most efficient option to do this.
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