我正在尝试在共享的webhost上创建Zend应用程序,我无法访问php.ini或其他任何内容。
Zend已设置并正在为索引控制器/视图工作。 但当我尝试访问另一个控制器/视图时,让我们说“mysite.com/About”我得到了这个错误:
Not Found
The requested URL /home/vhosting/g/vhostxx/domains/mysite.com/htdocs/projectname/public/index.php was not found on this server.
我的文件夹结构如下所示:http://framework.zend.com/wiki/display/ZFPROP/Zend+Framework+Default+Project+Structure+-+Wil+Sinclair(参见第9点)
根目录中的.htaccess(/home/vhosting/g/vhostxx/domains/mysite.com/htdocs/projectname)如下所示:
php_value include_path "/domains/mysite.com/htdocs/www/library"
Options All -Indexes
php_flag display_errors on
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
公用文件夹中的.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 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();
应用程序文件夹中的(空)引导程序:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
}
我正在尝试访问的控制器是:projectname / application / controllers / AboutController.php 哪个应该可以通过mysite.com/About访问,但我收到了前面提到的消息。
我真的不知道我做错了什么或我错过了什么。任何人都可以告诉我如何解决这个问题或如何调试它?
旁注:我的主人自动翻译
mysite.com/htdocs/projectname/
到
mysite.com/htdocs/www/
在ftp上,不确定这是否是一个问题,或通过http
访问它时发生答案 0 :(得分:4)
在公用文件夹的htaccess文件中,更改:
RewriteRule ^.*$ index.php [NC,L]
包含一个前导斜杠:
RewriteRule ^.*$ /index.php [NC,L]
Apache猜测重写规则的目标是什么,它是文件路径的URI路径,看起来它错误地猜测它是文件路径。您也可以在htaccess文件中添加一个基础:
RewriteBase /