4

我正在将一个 zend 项目myproject从本地主机部署到子目录 www.subdirectory.com/~username/ myproject,即使我已经读到从本地部署 zend 项目时没有太多需要更改,我也面临很多问题主机到子目录我已经尝试过这个 我从答案中得到的,但它没有用。

问题是当我将链接放在打开项目目录的文件树上方时,当我单击公共时,它会将我重定向到默认模块的索引页面。我不能去任何其他页面

我无法控制 apache2 服务器。有没有办法部署项目,这是我下面的代码,.htaccess任何答案或指导都会有帮助index.phpapplication.ini

.htaccess

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

索引.php

// Define path to application directory
defined('APPLICATION_PATH')
        || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define path to application directory
defined('PUBLIC_PATH')
        || define('PUBLIC_PATH', realpath(dirname(__FILE__)));


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


$paths = array(realpath(dirname(_FILE_) . '/../library'), '.');
set_include_path(implode(PATH_SEPARATOR, $paths));
/* Define the base URL */
define('URL_ADDRESS', "http://" . $_SERVER['HTTP_HOST']);


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

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

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

应用程序.ini

[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1    
includePaths.library = APPLICATION_PATH "/../library"
appnamespace = "Application"
resources.frontController.params.displayExceptions = 1
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view[] =
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.layout.layout = default    
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =    
autoloaderNamespaces.Hyderlib = "Hyderlib_"
resources.layout.pluginClass= "Hyderlib_Controller_Plugin_ModuleLayout"
resources.view[] = 

[staging : production]

[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


resources.db.adapter = "pdo_mysql"
resources.db.params.host = "password"
resources.db.params.username = "password"
resources.db.params.password = "password"
resources.db.params.dbname = "password"
resources.db.isDefaultTableAdapter = true
4

1 回答 1

1

看看这个:.htaccess RewriteRule not working in subdirectory

我怀疑您必须编辑 .htaccess 以通过不在同一目录中的 index.php 转发除 image/css/js 以外的请求。

如果网络服务器根目录是 ~/username/ 然后将 .htaccess 放在那里并更改

RewriteRule ^.*$ index.php [NC,L]

RewriteRule ^.*$ myproject/index.php [NC,L]

可能需要进行更多更改来处理静态内容(其他重写)。

于 2012-06-09T10:20:20.333 回答