2014-04-02 107 views
1

我開發Zend框架1.12Zend框架重定向問題:無效的控制器指定

一個項目,如果我把所有的文件在根文件夾中的一切工作正常,但如果沒有什麼創建一個新的文件夾,並將所有文件的工作。

以下是我的文件夾結構 應用 庫 公共 的index.php 的.htaccess

的.htaccess

SetEnv APPLICATION_ENV development 

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^js/(.*)$  public/js/$1 [L] 
RewriteRule ^images/(.*)$  public/images/$1 [L] 
RewriteRule ^css/(.*)$  public/css/$1 [L] 
RewriteRule ^.*$ index.php [NC,L] 

的application/config /的application.ini

[production] 
phpSettings.display_startup_errors = 1 
phpSettings.display_errors = 1 
includePaths.library = APPLICATION_PATH "/../library" 
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" 
bootstrap.class = "Bootstrap" 
appnamespace = "Application" 
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 
resources.frontController.params.displayExceptions = 1 

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" 

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/" 
resources.frontController.baseUrl = "/" 

resources.session.remember_me_seconds = 864000 


[staging : production] 

[testing : production] 

[development : production] 
phpSettings.display_startup_errors = 1 
phpSettings.display_errors = 1 
resources.frontController.params.displayExceptions = 1 
resources.db.adapter = "PDO_MYSQL" 
resources.db.params.host = "localhost" 
resources.db.params.username = "root" 
resources.db.params.password = "root123" 
resources.db.params.dbname = "labs" 
resources.db.isDefaultTableAdapter = true 
resources.db.params.profiler.enabled = true 
resources.db.params.profiler.class = Zend_Db_Profiler_Firebug 
includePaths.models = APPLICATION_PATH "/models/" 
resources.frontController.baseUrl = "/" 

如果我將實驗室中的所有文件夾移動並更改在作爲的application.ini
resources.frontController.baseUrl = 「/實驗室/」

http://domainname/ : Works fine  
https://domainname/labs : gives error 

如何解決這個問題。我想把所有文件放在新文件夾中,這樣在根目錄下我可以創建更多的項目。

ERROR

An error occurred 
Page not found 
Exception information: 

Message: Invalid controller specified (labs) 
Stack trace: 

#0 /var/www/html/labs/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) 
#1 /var/www/html/labs/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() 
#2 /var/www/html/labs/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() 
#3 /var/www/html/labs/index.php(30): Zend_Application->run() 
#4 {main} 

Request Parameters: 

array (
    'controller' => 'labs', 
    'action' => 'index', 
    'module' => 'default', 
) 

回答

0

也許你必須改變你的 「的baseUrl」 在您的配置文件。

resources.frontController.baseUrl = "/labs/" 

也許這樣的:How to set baseUrl

+0

沒有,甚至沒有工作 – user3165155

+0

看起來你必須改變你的配置文件和你的htaccess: http://blog.digitalpierce.com/2012/08/24/zend-framework-project-in -a子文件夾/ resources.frontController.baseUrl =「/ labs」 並在您的htaccess中添加「RewriteBase/labs」 –

0

無需在.htaccess

的application.ini變化去改變什麼作爲
resources.frontController.baseUrl = 「/實驗室」

添加在bootsrap.php中的函數下面,你會完成。

protected function _initBaseUrl() 
    { 
     $options = $this->getOptions(); 
     $baseUrl = isset($options['settings']['baseUrl']) 
      ? $options['settings']['baseUrl'] 
      : null; // null tells front controller to use autodiscovery, the default 
     $this->bootstrap('frontcontroller'); 
     $front = $this->getResource('frontcontroller'); 
     $front->setBaseUrl($baseUrl); 
    }