Forum Discussion
http domain redirect
you mean myhosts ? or myhost is an actual irule recognized command?
I do mean "myhost".
set myhost [class match -value [string tolower [HTTP::host]] equals myhosts]
set redirect 0
if { $myhost ne "" } {
set redirect 1
} else {
set myhost [HTTP::host]
}
If the class match returns a value and sets the myhost variable, then we simply set the redirect flag. Otherwise, we set the myhost variable to the actual host [HTTP::host]. In either case, the myhost variable contains a value in case the redirect flag is set and a redirect is issued.
Arguably option 2 will be the most difficult, given that your single data group may have MANY items to manage. Here's another option that combines options 1 and 3:
when HTTP_REQUEST {
set myhost [class match -value [string tolower [HTTP::host]] starts_with myhosts]
if { $myhost ne "" } {
HTTP::redirect "http://${myhost}[HTTP::uri]"
}
set myuri [class match -value [string tolower [HTTP::uri]] starts_with myuris]
if { $myuri ne "" } {
HTTP::redirect "http://[HTTP::host]${myuri}"
}
}
This will issue an initial redirect based on the host name, and then another based on the URI.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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