我希望服务器上的public_html文件夹成为zend项目中的公共(public)文件夹。
你们知道我该怎么做吗?现在,我必须使用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();
但这是行不通的。知道如何解决这个问题吗?
基本上我想要这样的目录结构:
public_html/
----application/
----library/
----index.php
还是有其他方法可以做到这一点?无论如何,我都希望从我的网址中删除“公开”。
有任何想法吗?
最佳答案
如果您的.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'
);
这是我的.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>