tags:

views:

108

answers:

1
"404" (controller: 'error', action: 'pageNotFound')

Any changes to response.status inside the pageNotFound action is reverted back to 404 before the response is sent to the client. Is it possible to work around this some way? I would like to be able to change it to 410 when I detect that the resource has been deleted or 301 when it's moved permanently.

A: 

If that's not working try this in your error controller:

class ErrorController {

    def notFound = {
        redirect( action: 'gone')
      }

    def gone= {
        response.sendError(410, "Gone")
    }
}
Dave
I actually ended up doing it this way, but I'm a little worried that it might confuse Google because it will return a 302 temporary redirect on the original page, and than the 410.
Kimble