Forum Discussion

Abhijith_Subban's avatar
Abhijith_Subban
Icon for Nimbostratus rankNimbostratus
Mar 19, 2018

irule based om http request.

I got a requirement as below :

 

When client hits abc-test-domain.com --- should get translated to dc-abc-test-domain1.com. Could someone give me the syntax please for irule.

 

14 Replies

  • oguzy's avatar
    oguzy
    Icon for Cirrostratus rankCirrostratus

    Hi,

    when HTTP_REQUEST { 
       if { [string tolower [HTTP::host]] equals "abc-test-domain.com" } {
          HTTP::respond 301 "Location" "http://dc-abc-test-domain1.com"
       }
    }
    
    • THi's avatar
      THi
      Icon for Nimbostratus rankNimbostratus

      Just a note on the 301 redirect:

       

      Instead of 301 Moved Permanently, I'd rather use 307 Temporary Redirect. Browsers may cache 301s indefinitely, and it may be difficult to remove the cache entry, if you need to modify the redirect location later on. Depending on browser, the 301 cache may persist over restarts..

       

      Some may use 302 redirects, but 307 will also keep the original HTTP method (eg. GET, POST, HEAD), 302 may not.

       

      So, I would try to avoid a 301 redirects, unless I were 100% sure of the need of permanently de-commissioning the old URL.

       

  • Hi,

    when HTTP_REQUEST { 
       if { [string tolower [HTTP::host]] equals "abc-test-domain.com" } {
          HTTP::respond 301 "Location" "http://dc-abc-test-domain1.com"
       }
    }
    
    • THi's avatar
      THi
      Icon for Nimbostratus rankNimbostratus

      Just a note on the 301 redirect:

       

      Instead of 301 Moved Permanently, I'd rather use 307 Temporary Redirect. Browsers may cache 301s indefinitely, and it may be difficult to remove the cache entry, if you need to modify the redirect location later on. Depending on browser, the 301 cache may persist over restarts..

       

      Some may use 302 redirects, but 307 will also keep the original HTTP method (eg. GET, POST, HEAD), 302 may not.

       

      So, I would try to avoid a 301 redirects, unless I were 100% sure of the need of permanently de-commissioning the old URL.