Forum Discussion
Hai_Le_36697
Nimbostratus
Sep 24, 2010redirect wwwX.domain.com to www.domain.com
Hey guys,
I'm pretty new to iRule and this forum has really helped me get to where I am; however, I am stuck and I hope you guys can help. What I would like to do is to extract the domain ...
hoolio
Cirrostratus
Sep 24, 2010Here's something that might work for you. I'm not sure what you want to do if the client either doesn't set a host header value or uses an IP address, so I've just left a comment in the default switch case.
when HTTP_REQUEST {
Check requested host set to lowercase
switch -glob [string tolower [HTTP::host]] {
"www.*" {
Host starts with www. so exit this event in this iRule
return
}
"*[a-z]*" {
Host isn't an IP and didn't start with www., so send permanent redirect
HTTP::respond 301 Location "http://www.[domain [HTTP::host] 2][HTTP::uri]"
}
default {
Host is either blank or an IP address, do something?
}
}
}
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