Forum Discussion

2 Replies

  • 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

    • Harishwar_Reddy's avatar
      Harishwar_Reddy
      Icon for Nimbostratus rankNimbostratus
      Thanks Vernon..I got my answer from my superior..he said we can only redirect to/from fully qualified domain names. http://harish/ is not fully qualified,