Forum Discussion
Alan_Evans_1020
Nimbostratus
May 24, 2011iRule to redirect to new name after given time
Our customer is going through a name change and we will need to redirect from oldname to newname starting on a given date. I realize I could just apply the iRule at the right time BUT why not automat...
Alan_Evans_1020
Nimbostratus
May 24, 2011Thank you Aaron for steering me in the right direction. I did discover one more thing. The 'info exists $static::' needs to be 'info exists static::' as is the whole problem here I don't understand TCL syntax to know why...
Here is the final result:
when RULE_INIT {
array set static::renameredirects {
app.example.com https://app.newexample.com
www.example.com http://www.newexample.com
}
Epoch time for 6/1/2011 00:00:00 EST
set static::renamecutovertime 1306900800
}
when HTTP_REQUEST {
if { ([clock seconds] > $static::renamecutovertime) && ([info exists static::renameredirects([string tolower [HTTP::host]])]) } {
log local0. "Redirecting to: $static::renameredirects([string tolower [HTTP::host]])[HTTP::uri]"
HTTP::redirect $static::renameredirects([string tolower [HTTP::host]])[HTTP::uri]
}
}Now we just put oldname newurl pairs in the RULE_INIT and no one has to wake up in the middle of the night to change it over on 6/1. Of course I will probably be awake then anyway... üôÇ
Regards,
-Alan
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