Zend Layout中的url链接自动附加在服务器上的~username

时间:2012-05-16 10:03:39

标签: zend-framework url

我正在为我的项目使用ZF,我的服务器目录结构是:

/ROOT
  __/APPLICATION
  __/Zend library
  __/public_html(I put all the contents of public folder created by ZF here)
  __/docs
  __library

我有一个.htaccess文件,我把它放在public_html文件夹中。有两个问题需要帮助。 第一,       我使用$ this-> url创建的网址链接(例如,数组('controller'=>'home','action'=>'index'),null,true)会导致{ {1}},其中'wethemen'是我在托管服务器帐户上的用户名。我在页面源中检查了它。这就是为什么它也不是渲染所请求的控制器和动作,可能是。

其次,        仅渲染布局而不执行任何操作。我的默认控制器是'home',所以当我尝试访问该站点时出现此错误。         脚本:在路径中找不到''home'/ index.phtml'(/ home1 / wethemen / application / views / scripts /)。

这是我第一次在服务器上部署ZF项目。任何帮助将不胜感激。如果需要,我会倒入index.php和bootstrap.php的内容。

1 个答案:

答案 0 :(得分:0)

刚刚放

$controller = Zend_Controller_Front::getInstance();
$controller->setBaseUrl('/your/base/url');

在调用dispatch()之前,您会在bootstrap中找到文本“ - > setRouter”或其他任何位置。

编辑:如果这不起作用并且您认为这是HTTP服务器重写问题,请添加

RewriteEngine on
RewriteBase /

如果您在http://yourdomain.com/访问了该应用程序 或

RewriteEngine on
RewriteBase /your/base/url/

如果应用程序被访问为http://yourdomain.com/your/base/url/