Forum Discussion
WWW redirect to HTTPS
i want to redirect whenever user type
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
Codewhen 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" } } }
CodePlease assist
5 Replies
- Matt_Dierick
Employee
You can use "contains" or "end_with" conditions instead of explicit string like "ircuat.abc.com".
- Wasim_Hassan_13
Nimbostratus
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" } }
- Matt_Dierick
Employee
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.
- Wasim_Hassan_13
Nimbostratus
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.
- Matt_Dierick
Employee
In that case, I would say, use switch command : https://devcentral.f5.com/articles/irules-101-04-switch
switch [HTTP::host] { "*ircuat.abc.com" { do something... } "*jobsuat.abc.com" { do something else... } default { don't do anything... } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com