【问题标题】:Deploy modular zend project on a sub-directory host在子目录主机上部署模块化 zend 项目
【发布时间】:2012-06-08 22:28:21
【问题描述】:

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

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

我无法控制 apache2 服务器。有没有办法部署项目,这是我下面的代码 .htaccessindex.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]

index.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

【问题讨论】:

    标签: zend-framework .htaccess php web-deployment-project subdirectory


    【解决方案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]
    

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

    【讨论】:

    • 谢谢 lucian303 这仍然没有帮助,问题似乎是如果任何请求是对任何页面(/default/index 页面除外),请求不会到达 index.php 文件公开。
    • 不用担心。您是否尝试过使用 apache 的 RewriteBase 指令?见:httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
    猜你喜欢
    • 2018-04-04
    • 1970-01-01
    • 2012-01-14
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多