Forum Discussion

Misty_Spillers's avatar
Misty_Spillers
Icon for Nimbostratus rankNimbostratus
Feb 28, 2012

Redirecting 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 it seems simple enough.

Our websites are laid out like this

www.main.com

www.main.com/agency1

www.main.com/agency2

Agency1 is getting a complete makeover and I want to redirect 404's just for them to their own page.

Why doesn't this rule work? (the 404 pages still show)



when HTTP_REQUEST {
   
     set uri [string tolower [HTTP::uri]]
}

when HTTP_RESPONSE {
   
     if { [HTTP::status] == 404 and $uri eq "/agency1"} {
      HTTP::redirect "http://www.main.com/agency1/moved.html"
   }
}

My only guess is that it never equals "agency1" if I remove the that part it redirect all 404's from www.main.com which makes sense.

Thanks in advance,

Misty

15 Replies