Forum Discussion

yihwen_100254's avatar
yihwen_100254
Icon for Nimbostratus rankNimbostratus
Jun 14, 2011

Generic iRule to redirect domain.com to www.domain.com

Hi

 

 

I am planning to create an generic iRule to perform a http://domain.com to https://www.domain.com I know in the F5 v10.x.x, there is a _sys_https_redirect and that will actually redirect any http:// to https://

 

 

But as most users love to type http://domain.com, I am thinking of creating a generic iRule so that I can use it for all my domains. Below is the iRule to perform what I want but this is not generic.

 

 

when HTTP_REQUEST {

 

if {

 

[HTTP::host] eq "domain.com" } {

 

HTTP::redirect "https://www.domain.com[HTTP::uri]"

 

}

 

}

 

 

If I have another domain called http://abc.com, using this iRule above will not work. What is the best way of achieving this?