Forum Discussion
Angel_Martinez_
Aug 04, 2011Nimbostratus
iRule vs HttpClass
Hi
Nowadays my customers ask me for many redirection, for example from http to https, from domain.com to www.domain.com... usually easy things...
User wants to force the Host header.
- Via iRule:
rule iRule_Redirect_www.domain.com {
when HTTP_REQUEST {
if { [HTTP::host] ne "www.domain.com" } {
HTTP::redirect "http://www.domain.com"
}
}
- Via Httpclass
May I do something like that ¿?
profile httpclass httpclass_www.domain.com {
defaults from httpclass
pool none
redirect "http://www.domain.com"
hosts regex "![^www.domain.com*]" --> I don't know how to do a Negative RegExp
}
But what is more effective ¿? which one is less painful for the CPU ¿?
Thank you
- It's always faster to execute logic like this natively in the product. But, in this case, "faster" can just mean you are shaving a couple dozen milliseconds off the request which is negligible. The bigger question you should ask yourself for situations like this is "what is more manageable". If it won't change very often and you just want to set it and forget it, then use the Class profile. But, if you want to have more control and options for expanding it (ie. adding elses and else-ifs), then an iRule might work out best for you.
- hoolioCirrostratusYou'd need to use a lookbehind to do a negative match with a regex. But you could instead create an HTTP class with a string pattern matching www.domain.com with no action and then create a match all HTTP class which redirects to http://www.domain.com. The string patterns would be more efficient than a regex anyhow.
- Angel_Martinez_NimbostratusHi Guys
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