Forum Discussion
iRule Assistance with redirecting multiple URLs to a single URL using an existing Redirect iRule
I currently have a universal redirect and have a requirement to add the below to this irule. Since I am unfamiliar with irules I am hoping a DevCentral community expert can assist.
I need to redirect these urls http://sitename.com, https://sitename.com, http://www.sitename.com & https://www.sitename.com
To this url https://www.sitename.io
Our current irule looks like this with several entries inside the beginning HTTP_REQUEST.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"*www.sitename.net*" {
HTTP::redirect "https://sitename.sitename.com"
}
default {
add the default action you prefer ie "www.def.com"
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
}
- jpeterson6_1656
Nimbostratus
Assuming you want to keep , the following additional entry should cover the four examples you listed:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "*www.sitename.net*" { HTTP::redirect "https://sitename.sitename.com" } "*sitename.com" { HTTP::redirect "https://www.sitename.io" } default { add the default action you prefer ie "www.def.com" HTTP::redirect "https://[HTTP::host][HTTP::uri]" } } }
- bwilliam
Cirrus
Thank you. A simple wildcard does the trick, go figure. I guess that makes sense given the sitename.com is static and we only want to trigger the redirect if any of the variables preceding sitename.com changes.
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