0

hello I am working in Zend. I want to know some thing about undefined URL handling. I have a url like http://localhost/concierge/login and it has the following rule in url rule file.

'admin/login' =>array('login', array('module'=>'admin','controller' => 'index','action' => 'login'),array(),'login'),. It all works fine.

But if if change the url like http://localhost/concierge/lgin which I have not defined it goes to a blank page where an empty array is shown and there is written Page not Found. IT looks bad. I want to know if user writes any thing wrong in url, My application should show 404 error.

Now I want to know How can I achieve my task? Will I have to define an other rule for url rules files to handle all these errors? If so how this url rule will look like? And for controllers what should I do? Any help ?

2

1 Answer 1

1

I do this using the preDispatch hook of a front controller plugin.

public function preDispatch(Zend_Controller_Request_Abstract $request) { $disp = Zend_Controller_Front::getInstance()->getDispatcher();

    if ( !$disp->isDispatchable($request) ) { 
            $request->setModuleName('default'); 
            $request->setControllerName('error'); 
            $request->setActionName('error404'); 
    } 

}

if the thing doesn't exist ( /registerxxx instead of /register for example ) then they get bounced to a 404 page. It has worked so far for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.