Forum Discussion
bilco105_9926
Jan 14, 2008Nimbostratus
404/403 Redirect
Hi Folks,
I am looking to create an iRule that redirects to a generic www.domain.com/404.html whenever a 404 response is hit. This is obviously easy using HTTP::redirect. However, when I do this, The F5 returns a 200 response code.
I need the rule to initially return a 404 for the requested URL (for SEO), then redirect over to my generic 404 page (for client-side usability).
I have a working concept, which is as follows..;
when HTTP_RESPONSE {
Handle error status' nicely
switch [HTTP::status] {
"403" {
log local0.notice "Caught 403, redirecting to generic page"
HTTP::respond 403 content [subst $::error_404] "Content-Type" "text/html; charset=UTF-8"
}
"404" {
log local0.notice "Caught 404, redirecting to generic page"
HTTP::respond 404 content [subst $::error_404] "Content-Type" "text/html; charset=UTF-8"
}
"500" {
log local0.notice "Caught 500, redirecting to generic page"
HTTP::redirect "http://www.domain.com/techdifficult.html"
}
}
}
Then, my error_404 is defined as html, which contains a meta-refresh to the 404/403 page. This is a pretty ugly way of doing this.
Is there a better way?
Thanks
- hooleylistCirrostratusHello,
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