Forum Discussion
Ryan_Rowe_79249
Nimbostratus
Jan 12, 2010HTTP host Redirect Irule
OK this is a little different the the other irules but this is what I want to do. I want to use a switch statement to reform the IP.
So for example when someone comes as x.domain.com I want it to redirect it to www.domain.com/x
Does anyone know the easiest way to do this.
1 Reply
- Thomas_Schaefer
Nimbostratus
Do you want the end user to see the switch or do you just want to pass it through to the new address? You said you wanted to use a switch statement but I am not sure why in this case.
The answer also depends upon how generic you need to make this. If the domain is known, you can use this code to get the first part of the FQDN:
HTTP::redirect http://www.domain.com/[getfield [HTTP::host] "." 1][HTTP::uri]
This grabs the first string before the . and adds it to the end. I also added HTTP::uri as I presume you want to make sure anything sent on input is kept with the request.
The getfield page on the wiki has some good examples of this.
If this could be for one of many domain names, then you need to grab the remainder of the string and use that. You also need to address if the browser came in https and redirect accordingly.
Regards,
Tom
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
