Forum Discussion
Bryce_Halkerst1
Nimbostratus
Oct 14, 2015Domain Redirect iRule
All,
Having issues with setting up irule to redirect any host equals with URL = / to redirect to the home page, then allowing anything coming over with /* to maintain the full path. Seems pretty str...
Stanislas_Piro2
Cumulonimbus
Oct 14, 2015Hi, there are multiple syntax errors in the irule.
try the following irules:
when HTTP_REQUEST {
Domain 301 Redirect
if { ([HTTP::host] equals "www.blah.com" ) or ([HTTP::host] equals "10.10.10.10") or ([HTTP::host] equals "blah.com") } {
if { ([HTTP::uri] equals "/") } {
HTTP::respond 301 Location "http://www.blah.com/home/index.jsp"
} elseif { !([HTTP::host] equals "www.blah.com") } {
HTTP::respond 301 Location "http://www.blah.com[HTTP::uri]
}
}
}
or use a switch command:
when HTTP_REQUEST {
switch -glob [string to lower [HTTP::host][HTTP::path]] {
"www.blah.com/" -
"blah.com/" -
"10.10.10.10/" {HTTP::respond 301 Location "http://www.blah.com/home/index.jsp"}
"blah.com/*" -
"10.10.10.10/*" {HTTP::respond 301 Location "http://www.blah.com[HTTP::uri]"}
}
}
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