Forum Discussion

Jason_40769's avatar
Jason_40769
Icon for Nimbostratus rankNimbostratus
Jul 12, 2011

redirect that passes all other traffic

I have been trying to create an irule that will redirect the primary site from its http version to its https version but still allows http subsite traffic to pass

 

 

For example

 

 

 

when HTTP_REQUEST {

 

 

 

 

 

if { [HTTP::host] == "mysite.fun.com"}{

 

HTTP::redirect "https://mysite.fun.com[http_uri]"

 

}

 

 

 

}

 

 

 

 

-------

 

So if someone types http://mysite.fun.com i want them to go to https://mysite.fun.com

 

 

 

but if someone types http://mysite.fun.com/players i want them to go to http://mysite.fun.com

 

 

 

please advise

 

5 Replies

  • Hi Jason,

    So you want to redirect any request for mysite.fun.com with a URI of / to https, but leave all other requests alone? How about this then?

    when HTTP_REQUEST {
       if { "[string tolower [HTTP::host]][HTTP::uri]" eq "mysite.fun.com/"}{
          HTTP::redirect "https://mysite.fun.com/"
       }
    }
    

    Aaron
  • Thanks this worked great! I tried something very similar to this but i didnt try the string to lower command.