Zend Framework How to disable a controller

223 views Asked by At

When I put this addres example.com/js/config I need to load a config file for JS but router loading a controller and displays error beacouse the controller dosn't exists. In bootstrap file I put a _init method:

 protected function _initJsConfig(){
    $this->bootstrap('frontController');
    $oFront = $this->getResource('frontController');
    $oFront->setRequest(new Zend_Controller_Request_Http());
    $oRequest = $oFront->getRequest();
    $oRequest->setDispatched(false);
    //$oFront = Zend_Controller_Front::getInstance()->getRequest();
    if($oRequest->getControllerName() == 'js' && $oRequest->getActionName() == 'config'){
        include('/config/config.js.php');

        return;
    }
}

But this doesn't work. Any ideas? Best regards.

1

There are 1 answers

0
RockyFord On

The default ZF .htaccess will not serve .php files other then index.php from the public folder so move that .php file out of the public space.

Put it in application/configs or someplace similar.

You could probably modify your .htaccess to allow just that one .php file to be served but you really don't want arbitrary .php files in the public space on your server.