Forum Discussion

bilco105_9926's avatar
bilco105_9926
Icon for Nimbostratus rankNimbostratus
Jan 14, 2008

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
  • Hello,

     

     

    This page (Click here) seems to agree with your methodology.

     

     

    Considering that you want to give a specific response for search engines but display something else for clients, I'd say you've come up with a good solution. You could also change the web app to do this. I assume you already considered that though.

     

     

    Does the iRule solution work for you? Is there something else you want to do with the rule?

     

     

    Aaron