在Zend_Framework项目中更改公用文件夹位置?

6 php directory zend-framework public

我希望我的服务器上的public_html文件夹成为我的zend项目中的公共文件夹.你们知道我怎么能这样做吗?现在我必须使用domain.com/public查看我的网站

我尝试将index.php文件更改为此(更改了目录)

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

// 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';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();
Run Code Online (Sandbox Code Playgroud)

但这不起作用.知道如何解决这个问题吗?

基本上我想要一个像这样的目录结构:

public_html/
----application/
----library/
----index.php
Run Code Online (Sandbox Code Playgroud)

或者还有其他方法可以实现这一目标吗?无论如何,我希望"公开"从我的网址中删除.

有任何想法吗?

Asc*_*rer 3

如果您的 .htaccess 设置正确,您不必担心人们访问您的库文件夹,简单的重写规则可以防止这种情况。

下面是我用来删除 index.php 上的 public 目录的方法

$path = realpath(dirname(__FILE__));
$dirs = array(
        $path . '/library',
        get_include_path()
);
$includes = implode(PATH_SEPARATOR, $dirs);
set_include_path($includes);

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

defined('APPLICATION_ENV')
        || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

require_once 'Zend/Application.php';

$application = new Zend_Application(
                APPLICATION_ENV,
                APPLICATION_PATH . '/configs/application.ini'
);
Run Code Online (Sandbox Code Playgroud)

这是我的 .htaccess

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options -Indexes
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]
RewriteRule \.svn/.* index.php [L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)