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 29, 2012So to keep it dynamic, you could grab the host header on HTTP_RESPONSE, and use that variable later on down the line.
when HTTP_REQUEST {
set host [string tolower [HTTP::host]]
set path [string tolower [HTTP::path]]
}
when HTTP_RESPONSE {
switch [HTTP::status] {
"404" {
switch -glob $path {
"/agency1*" {
HTTP::respond 301 \
"Location" "http://$host/agency1/moved.html" \
"Server" "$host"
}
"/agency2*" {
HTTP::respond 301 \
"Location" "http://$host/agency2/moved.html" \
"Server" "$host"
}
}
}
}
}
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
