Forum Discussion

Wasim_Hassan_13's avatar
Wasim_Hassan_13
Icon for Nimbostratus rankNimbostratus
Oct 29, 2014

WWW redirect to HTTPS

i want to redirect whenever user type

 

www.jobsuat.abc.com

 

https://jobsuat.abc.com

 

http://jobsuat.abc.com

 

to redirect to

 

https://ebsdmzuat.abc.com/OA_HTML/IrcVisitor.jsp

 

currently i have the following iRule but it is only redirecting if

 

https://jobsuat.abc.com https://ircuat.abc.com

 

not with www.jobsuat.abc.com or www.ircuat.abc.com

 

Code

when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "ircuat.abc.com" { HTTP::respond 301 Location "https://ebsdmzuat.abc.com/OA_HTML/IrcVisitor.jsp" } "jobsuat.abc.com" { HTTP::respond 301 Location "https://ebsdmzuat.abc.com/OA_HTML/IrcVisitor.jsp" } "careersuat.abc.com" { HTTP::respond 301 Location "https://ebsdmzuat.abc.com/OA_HTML/IrcVisitor.jsp" } } }

 

Code

Please assist

 

5 Replies

  • You can use "contains" or "end_with" conditions instead of explicit string like "ircuat.abc.com".

     

  • thanks for the reply you mean to say the irule will look like that

     

    when HTTP_REQUEST { if { (([HTTP::host] equals "abc.com") or ([HTTP::host] equals "www.jobsuat.abc.com")) } { HTTP::redirect "https://ebsdmzuat.abc.com/OA_HTML/IrcVisitor.jsp" } }

     

    or

     

    when HTTP_REQUEST { if { (([HTTP::host] contians "abc.com") { HTTP::redirect "https://ebsdmzuat.abc.com/OA_HTML/IrcVisitor.jsp" } }

     

  • Correct :) Be careful to do not assign this irule to the VS presenting "https://ebsdmzuat.abc.com/OA_HTML/IrcVisitor.jsp" --> you will see nice loop.

     

  • hi,

     

    i tried with

     

    when HTTP_REQUEST { if { (([HTTP::host] equals "ircuat.abc.com") or ([HTTP::host] equals "www.ircuat.abc.com")) } { HTTP::redirect "https://ebsdmzuat.abc.com/OA_HTML/IrcVisitor.jsp" } }

     

    now i want to add other sites as well in this irule how can i add it i am getting erros.

     

    jobsuat.abc.com carrers.abc.com

     

    please help.