Custom 404 error page

Discussion in 'Customization & add-ons' started by borise, Apr 10, 2013.

  1. borise

    borise Member

    Joined:
    Jan 3, 2013
    Messages:
    42
    Hey guys,

    Looking for a way to use a custom 404 error page. Right now, the following text is displayed on 404 page:

    Code:
    HTTP/1.1 404 Not Found
    which is found in library/Am/App.php on line 1927:
    PHP:
        function __exception404(Zend_Controller_Response_Abstract $response)
        {
            
    $response
                
    ->setHttpResponseCode(404)
                ->
    setBody('HTTP/1.1 404 Not Found')
                ->
    setRawHeader('HTTP/1.1 404 Not Found')
                ->
    sendResponse();
        }
    Does anyone know how to edit the code in order to redirect to a custom 404 page?

    I've tried adding ErrorDocument in .htaccess, but this doesn't do the trick.

    Thanks!
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Replace that code to:
    PHP:
      function __exception404(Zend_Controller_Response_Abstract $response)
        {
            
    $response->setRedirect($url);
         }
    Also we will implement this in core:
    http://bt.amember.com/issues/1176
  3. borise

    borise Member

    Joined:
    Jan 3, 2013
    Messages:
    42
    Thanks Alexander.

    Replacing the code didn't work.

    I googled around and found a solution that did work:

    http://stackoverflow.com/questions/3388624/zend-controller-requestsetredirect-does-not-seem-to-work

    so this is what I got now (and working):
    PHP:
        function __exception404(Zend_Controller_Response_Abstract $response)
        {
            
    $url "/404";
            
    $response->setRedirect($url);
            
    $response->sendHeaders();
            exit();
        }
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Yes sorry, I removed too many lines :)

Share This Page