Universal HTTP host redirect

Problem this snippet solves:

Are you tired of chewing up external public IP's well this iRule may be for you. This simple iRule will allow you to redirect clients to specific url's based on host header information, the default action will just redirect to HTTPS or whatever you choose. Enjoy!

Code :

when HTTP_REQUEST {
   switch -glob [string tolower [HTTP::host]] {
      "*abc*" {
         # add the redirect link ie "www.xyz.com"
         HTTP::redirect "https://www.xyz.com/xyz"
      }
      default {
         # add the default action you prefer ie "www.def.com"
         HTTP::redirect "https://[HTTP::host][HTTP::uri]"
      }
   }
}
Published Mar 18, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment