Forum Discussion

Justin_Adrian_3's avatar
Justin_Adrian_3
Icon for Nimbostratus rankNimbostratus
Oct 01, 2009

IRule Sharing, Vanity IRules

I have a customer who uses a massive volume of vanity hostnames for their websites. It was getting unruly to use an irule with a switch clause to support them.

So I came up with this solution.

when HTTP_REQUEST { 
 log local0.info [string tolower [HTTP::uri]] 
 log local0.info [findclass [string tolower [HTTP::uri]] [set ::VURL_[string tolower [HTTP::host]]] " "] 
  redirect to URL in data set 
 HTTP::redirect  [findclass [string tolower [HTTP::uri]] [set ::VURL_[string tolower [HTTP::host]]] " "] 
 }

The way it works is as follows.

Create a single Virtual server and assign this IRule as its resource.

for each of your VANITY urls, create a dataset as follows

class VURL_test.vanity.com "/ http://somenew.url.here.com"

The irule will look at the host header, search for the dataset named after the host header, search for any custom parameters for redirection and then redirect.

This will work with a simple host to host redirection as I put in the class example, or you could go further with it like below.

class VURL_xyz.test.com  { 
    "/.NetCoP https://xxx.foo.com/Communities/Pages/DotNET-ACA.aspx" 
    "/ADA https://xxx.foo.com/Offerings/Pages/DeliveryArchitectures 
 .aspx " 
    "/AR Assets https://yyy.bar.com/Organizations/Pages/AR-Asset%20Strategy. 
 aspx" 
    "/AppRenewal https://test.site.com/Organizations/Pages/Tech-AR.aspx" 
 }

The only gotcha is that when you create your dataset, the hostname portion must be in lower case.

Enjoy

-J