zendframework 2 中的路径问题

path issue in zendframework 2

目前我正在将 zend 2 从一个服务器转移到另一个服务器。我遇到了一些路径问题。当我使用 index.php 访问文件时,它只工作一次,然后停止工作。像 url - 11.11.11.11/index.php/user/login。在这种情况下,它一次和设置用户名和密码后工作正常。它停止工作。

我所做的是将服务器指向公共文件夹

.htaccess 文件

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>

application.ini

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.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
    resources.layout.layout = "default"

    [staging : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1

    [testing : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1

    [development : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    resources.frontController.params.displayExceptions = 1

    database.host = "localhost"
    database.username = "xxx"
    database.password = 'xxxxxx'
    database.dbname = "xxx"

    autoloadernamespaces[] = "Resources_"
    autoloadernamespaces[] = "Plugins"
    resources.frontController.plugins[] = "Plugins_ViewSetup"

index.php 在 public 文件夹中

    defined('BASE_URL')
                || define('BASE_URL', 'http://11.11.11.11'); // Live

    defined('APPLICATION_PATH')
            || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

    defined('CHARTS_FONT_PATH')
            || define('CHARTS_FONT_PATH', realpath(dirname(__FILE__) . '/../library/Charts/fonts'));

    defined('PUBLIC_FOLDER')
            || define('PUBLIC_FOLDER', 'public');

    defined('DATA_UPLOAD_PATH')
            || define('DATA_UPLOAD_PATH', realpath(dirname(__FILE__) . '/data'));

    // Define application environment
    defined('APPLICATION_ENV')
            || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

    // Ensure library/ is on include_path
    set_include_path(implode(PATH_SEPARATOR, array(
                realpath(APPLICATION_PATH . '/../library'),
                get_include_path(),
            )));

    /** Zend_Application */
    require_once 'Zend/Application.php';

    /** Utilities */
    require_once 'Utils.php';

    // Create application, bootstrap, and run
    $application = new Zend_Application(
                    APPLICATION_ENV,
                    APPLICATION_PATH . '/configs/application.ini'
    );


    $application->bootstrap()
            ->run();

我已经通过启用 Apache mod_rewrite

解决了这个问题