zendframework中的路径问题2

时间:2017-08-05 07:04:40

标签: zend-framework zend-framework2

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

我所做的是在pulic文件夹上指向服务器

.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

    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();

1 个答案:

答案 0 :(得分:0)

我已通过启用Apache mod_rewrite

解决了这个问题