-1

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
    If the controller doesn't exist but the request is still getting routed to ZF, I would guess that the file `js/config` doesn't exist on the server or your .htaccess rules for ZF are not set up quite right. – drew010 Nov 14 '12 at 18:58
  • I know that I can edit the .htaccess file to disable route, but I wanted to hide a file, so that no one could see its extension (.php).So when I put this: I want to start: config.js.php file. Best regards. – Michał Kalkowski Nov 15 '12 at 14:18
  • 2
    The code you have won't work in the bootstrap because routes have not been established and no dispatching has been done. You can write a [controller plugin](http://framework.zend.com/manual/1.12/en/zend.controller.plugins.html) containing similar code to what you have because you can intercept the controller and action before it actually gets dispatched (to the non-existent controller and then error handled). – drew010 Nov 15 '12 at 16:30

1 Answers1

0

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.

RockyFord
  • 8,529
  • 1
  • 15
  • 21