Harishwar_Reddy
Jul 07, 2015Nimbostratus
Irule
I need a Irule which redirect to http://www.harish.com/ . Any one help us on this irule.
I need a Irule which redirect to http://www.harish.com/ . Any one help us on this irule.
Whether or not you can actually do this will depend on what your user-agent (typically a browser) actually sends when you enter . Many user-agents will expand this by affixing a domain from the OS provided search order. If that happens, then the hostname that needs to be redirected is not , but rather something else.
Having said that, there are several ways to handle this. One way is to use an iRule, as you suggest:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "harish" } {
HTTP::redirect http://www.harish.com[HTTP::uri]
}
}
I assume here that you wish to maintain whatever request-URI was included in the original request. If you do not want that, you may simply omit the [HTTP::uri] part.
However, if you are using 11.4 or higher, you should consider using a Local Traffic Policy. It is likely faster, and in any case, does not require code:
https://support.f5.com/kb/en-us/solutions/public/15000/000/sol15085.html
If you are using a version before 11.4, you can use an HTTP Class to accomplish this:
https://support.f5.com/kb/en-us/solutions/public/7000/200/sol7280.html