Forum Discussion
Pete_Paiva_7147
Jul 24, 2017Nimbostratus
iRule redirect based on hostname
Looking for some assistance in creating an iRule that would do the following:
User goes to http://one.abc.com/* redirect to http://one.xyz.com/sites/sync/SitePages/Home.aspx
However, if use...
- Jul 24, 2017
Try something like this:
when HTTP_REQUEST { if {[string tolower [HTTP::host]] equals "one.abc.com"}{ if {not (([string tolower [HTTP::path]] starts_with "/sites/hr") || ([string tolower [HTTP::path]] equals "/pages/aboutme.aspx"))}{ HTTP::redirect "http://one.xyz.com/sites/sync/SitePages/Home.aspx" } } }
https://devcentral.f5.com/wiki/iRules.HTTP.ashx
https://devcentral.f5.com/wiki/iRules.HTTP__host.ashx
Brad_Parker_139
Nacreous
Try something like this:
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] equals "one.abc.com"}{
if {not (([string tolower [HTTP::path]] starts_with "/sites/hr") || ([string tolower [HTTP::path]] equals "/pages/aboutme.aspx"))}{
HTTP::redirect "http://one.xyz.com/sites/sync/SitePages/Home.aspx"
}
}
}
https://devcentral.f5.com/wiki/iRules.HTTP.ashx
https://devcentral.f5.com/wiki/iRules.HTTP__host.ashx
hooleylist
Jul 25, 2017Cirrostratus
You can use a switch statement to avoid setting the HTTP::path value to lowercase twice:
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] equals "one.abc.com"}{
switch [string tolower [HTTP::path]] {
"/sites/hr" -
"/pages/aboutme.aspx" {
Do nothing and allow request to go to virtual server default pool
}
default {
For all other requests, redirect to new URL
HTTP::redirect "http://one.xyz.com/sites/sync/SitePages/Home.aspx"
}
}
}
}
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