Forum Discussion
macf5_119017
Nimbostratus
Dec 21, 2012Best way to redirect http and https to another https site
Looking for some assistance/guidance on configuring an iRule that will redirect http and https traffic to our google apps login page. We currently use SAML for our login page but that will be...
Michael_Yates
Nimbostratus
Dec 21, 2012Hi macf5,
I didn't experience the issue that you did with the redirect not working on HTTPS, but there are several ways you could do this.
If you will be adding to the number of sites that map to the same Virtual Server you could use a Switch Statement or make the redirect more dynamic. In my example below I made it a Permanent 301 Redirect:
Switch Method:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"www.website.com" -
"www1.website.com" { HTTP::respond 301 Location "https://[getfield [HTTP::host] ":" 1]/a[HTTP::uri]" }
"www2.website.com" -
"www3.website.com" { HTTP::respond 301 Location "https://[getfield [HTTP::host] ":" 1]/b[HTTP::uri]" }
}
}
Dynamic 301
when HTTP_REQUEST {
HTTP::respond 301 Location "https://[getfield [HTTP::host] ":" 1]/b[HTTP::uri]"
}
Hope this helps.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects