Forum Discussion

Andrea_Arquint's avatar
Andrea_Arquint
Icon for Nimbostratus rankNimbostratus
Apr 15, 2010

string substitution

Hi

 

 

I want to create an iRule which does the following:

 

 

 

when HTTP_REQUEST {

 

 

set host_orig [string tolower [HTTP::host]]

 

 

if { $host_orig contains ".gtm"} {

 

 

remove the string ".gtm" and return the modified "host" without the string ".gtm" in it

 

 

}

 

}

 

 

 

If I would request "www.gtm.mydom.com" then I will be redirected to www.mydom.com dynamically.

 

Even for example for:

 

 

test.gtm.mydom.com

 

www.gtm.otherdom.net

 

www.gtm.nextdom.org

 

asf

 

 

 

 

Why do I need this?

 

We use GTM's and our DNS provider does delegating everything "gtm.mydom.com" to both of our GTM's. So that's why "http://gtm.mydom.com can be resolved what we don't want.

 

 

 

 

Thanx for any help

 

 

:-)

 

1 Reply

  • How about this to send a permanent redirect to the requested host with the .gtm removed?

    
    when HTTP_REQUEST {
    
       if {[string tolower [HTTP::host]] contains ".gtm."}{
          HTTP::respond 301 Location "[string map {gtm. ""} [HTTP::host]]"
       }
    }
    

    Aaron