我正在尝试上传使用 Yii 框架创建的网页。我想使用免费托管,所以我使用了 000webhost.com。当我使用 FileZilla 上传网页并在网络浏览器中插入 URL 时,我看到以下错误:
Warning: require_once(/home/username/public_html/../yii/framework/yii.php [function.require-once]: failed to open stream: No such file or directory in /home/username/public_html/index.php on line 12
Fatal error: require_once() [function.require]: Failed opening required '/home/username/public_html/../yii/framework/yii.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/public_html/index.php on line 12
我认为我应该将Yii包括在托管中,但说实话,我不知道该怎么做。
有人可以帮助我吗?
谢谢
编辑:
我的主菜单是:
<div id="mainmenu">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
array('label'=>'Contact', 'url'=>array('/site/contact')),
array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
)); ?>
我的结构文件夹是:
public_html/themes/verde/views/layout/main.php
public_html/protected/views/site/index
public_html/protected/views/site/contact
public_html/protected/views/site/login
public_html/protected/views/site/pages/about
你需要将 Yii 框架上传到你的虚拟主机。之后,请确保它位于正确的目录中。我虽然你可以更改索引.php文件中的路径。(如果您确定已将其上传到正确的目录但仍然收到错误,请为文件夹提供足够的读/写访问权限)
您的应用程序是否位于名为"站点"的文件夹中? 您应该转到受保护/查看/布局并编辑主.php到正确的链接
<div id="mainmenu">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'xxx', 'url'=>array('xxx')),
...........
)
))
你应该有类似的东西。 编辑 'url'=>array('xxx') 以匹配正确的地址
编辑
在public_html文件夹中找到您的 .htaccess 并将其放入其中(仅此)
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule ^.*$ index.php [L]
之后转到受保护/配置/主.php并在组件数组中放置(或取消注释)这个
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:w+>/<id:d+>'=>'<controller>/view',
'<controller:w+>/<action:w+>/<id:d+>'=>'<controller>/<action>',
'<controller:w+>/<action:w+>'=>'<controller>/<action>',
),
),
这应该可以解决您的网址问题。