Forum Discussion

Mike_Monti's avatar
Mike_Monti
Icon for Nimbostratus rankNimbostratus
Mar 18, 2022

iRule that saves subdomain

I have a number of different subdomains (wwwdev, wwwapps, things like that) and I want to use an iRule to force the domain from .com to .org. 

Example force anyone that types in wwwdev.mydomain.com to arrive at wwwdev.mydomain.org

I've historically set this up using specific iRules for each subdomain, one on each farm. but that ends up being a lot of iRules that have to be updated when I'm sure I could just make one iRule that could be plugged in everywhere.  I'm also pretty sure this is an easy fix but my googling just isn't cutting it.

 

Any help would be appreciated!

Thanks,

Mike

 

 

  • Hi Mike,

    Can you try this iRule?

    when HTTP_REQUEST {
    	if { [HTTP::host] ends_with ".mydoamin.com" } {
    		HTTP::redirect https://[string map {".com" ".org"} [HTTP::host]][HTTP::uri]
    		return
    	}
    }
  • Hi Mike,

    Can you try this iRule?

    when HTTP_REQUEST {
    	if { [HTTP::host] ends_with ".mydoamin.com" } {
    		HTTP::redirect https://[string map {".com" ".org"} [HTTP::host]][HTTP::uri]
    		return
    	}
    }
  • Thanks for this, I've thrown it into dev and am checking it in a few places. So far so good!