Forum Discussion
HTTP Redirect to Different Domain
Hi,
I am fairly new to F5 irules and i have been tasked with setting up a redirect from a marketing url to the login of an already established site within our company. I am using a simple url redirect:
when HTTP_REQUEST { HTTP::respond 301 "Location" "http://sub.domain.com[HTTP::uri]OLA/faces/login.jspx?" }
The problem is we have two sites already point to the virtual server that uses an irule to redirect the url for sub.domain.com and domain2.com to https and adding the uri that i have above. Is there a way that to have a statment something like
If the request equals www.sub.com redirect to "http://sub.domain.com[HTTP::uri]OLA/faces/login.jspx?" else take the host which would be sub.domain.com or domain2.com and add the uri at the end?
Thanks
2 Replies
- Kevin_Stewart
Employee
Something like this perhaps:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "www.sub.com" { HTTP::respond 301 Location "http://sub.domain.com[HTTP::uri]OLA/faces/login.jspx?" } "sub.domain.com" - "domain2.com" { HTTP::respond 301 Location "https://sub.domain.com[HTTP::uri]OLA/faces/login.jspx?" } } } - JRahm
Admin
What URLs on those hosts do you want to send to a login page? Do you want to tie that to the presence of a session of a cookie? Might end up with some redirect loops otherwise. The basic structure you are looking for:
when HTTP_REQUEST { switch [HTTP::host] { "www.sub.com" { if { [string tolower [HTTP::uri]] eq "" } { HTTP::respond 301 Location "http://sub.domain.com/OLA/faces/login.jspx?" } } "sub.domain.com" - "domain2.com" { if { [string tolower [HTTP::uri]] eq "" } { HTTP::respond 301 Location "http://[HTTP::host]/OLA/faces/login.jspx?" } } default { reject } } }
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
