Forum Discussion
Greg_Bishop_104
Jun 27, 2011Nimbostratus
redirect 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...
Greg_Bishop_104
Mar 01, 2013Nimbostratus
I've been using the below code flawlessly for a couple of years now (funny, I found this post again from Google searching). I could now use an update if someone would be so kind: I need to check and remove if someone has www. in front of the subdomain intended. Using my original example:
greg.domain.com --> www.domain.com/sites/greg
bob.domain.dom --> www.domain.com/sites/bob
www.greg.domain.com --> www.domain.com/sites/greg
www.bob.domain.com --> www.domain.com/sites/bob
when HTTP_REQUEST {
Check for a non-null length host header
if {[string match {*[a-zA-Z]*} [HTTP::host]]}{
Use the getfield command to parse the subdomain
set subdomain [getfield [HTTP::host] . 1]
HTTP::redirect http://www.domain.com/sites/$subdomain
}
}
Any help appreciated! Thanks!
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