Forum Discussion
Misty_Spillers
Nimbostratus
Feb 28, 2012Redirecting 404 to a friendly page by uri
I have done lots of searching and have even come across posts of exactly what I want to do but is doesn't seem to work for me. I'm wondering if I'm running into a problem because I'm running 9.4.4 but...
Wil_Schultz_101
Nimbostratus
Feb 28, 2012I try to stay away from if statements, no good excuse other than switches are sometimes faster.
Try this, it should do the trick for you.
when HTTP_REQUEST {
set path [string tolower [HTTP::path]]
}
when HTTP_RESPONSE {
switch [HTTP::status] {
"404" {
switch -glob $path {
"/agency1" {
HTTP::respond 301 \
"Location" "http://www.main.com/agency1/moved.html" \
"Server" "www.main.com"
}
}
}
}
}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
