Forum Discussion
ukitsysadmin_95
Nimbostratus
Jun 04, 2009redirect example.xx to www.example.xx
Hello
I'm new to irules, and would love some help on creating an irule for my problem below
Our web farm hosts a single domain name, but multiple geographic suffix's. e....
hoolio
Cirrostratus
Jun 15, 2009If you only want to redirect domains which are listed in a datagroup, you could define them in a datagroup in lowercase and then use an iRule like this:
when HTTP_REQUEST {
Check if Host header is present with a length
if {[string length [HTTP::host]]}{
Save host header value in lowercase
set host [string tolower [HTTP::host]]
Check if Host header does not start with www
if {!($host starts_with "www.")}{
Check if host is listed in the domain datagroup
if {[matchclass $host equals $::domains_to_redirect]}{
Redirect client to same URI but with www prepended to the host header value
HTTP::redirect "http://www.[HTTP::host][HTTP::uri]"
}
}
}
}
Aaron
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