Forum Discussion
slackwaresuppor
Nimbostratus
May 28, 2008stripping data
how would i strip the www. off of www.domain.com??
May 28, 2008
In this example you are doing the getfield twice which is causing double string allocations. If all you want to do is check whether a "www." is prefixing your domain, you can do so with the "starts_with" operator. And then, since you know you want to strip off the first 4 characters, you can use the "string range" command to do that.
This code will set a variable to the value of the requested HTTP::host. If that value starts with a "www.", it will strip the "www." off and assign that to the variable. It will then issue a redirect with either the original or stripped host value.
when HTTP_REQUEST {
set host [HTTP::host]
if { [HTTP::host] starts_with "www." } {
set host [string range [HTTP::host] 4 end]
}
HTTP::redirect "https://www.domain1.com/nsa/+homePage=$host"
}
Is this what you are going for?
Oh, BTW, make sure you don't have this iRule on your www.domain1.com virtual or you'll get yourself into an infinite loop.
-Joe
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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