Forum Discussion
OTS02
Cirrus
Aug 19, 2015Is it possible to use an LTM Policy for sending 301 redirects?
Am experimenting with Policies. Hoping it is possible to send 301 redirects with a Policy.
Steve_Dionne
Nimbostratus
Mar 15, 2017ltm policy http2httpsredirect_301_pol {
last-modified 2017-01-19:10:44:32
requires { http }
rules {
http2httpsredirect_301_rule {
actions {
0 {
tcl
set-variable
expression "https://[getfield [HTTP::host] \":\" 1][HTTP::uri]"
name Redirect
}
}
conditions {
0 {
http-uri
port
values { 80 }
}
}
}
}
status published
strategy first-match
}
then the iRule is like this:
ltm rule redirect_from_local_traffic_policy_301_irule {
Redirect from Local Traffic Policy
to use it, create an action
tcl set variable
- name : Redirect
- expression : Redirect URL
when HTTP_REQUEST {
if {([info exists "Redirect"])} {
HTTP::respond 301 Location $Redirect
return
}
}
}
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