Zend Framework $this->baseUrl() 总是返回当前页面 :( 为什么 [英] Zend Framework $this->baseUrl() always returns the current page :( why

查看:22
本文介绍了Zend Framework $this->baseUrl() 总是返回当前页面 :( 为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看本网站 www.fltdata.com.出于某种原因,无论您访问哪个页面,主页链接都不是指向主页,而是指向当前页面.它在我的本地主机上运行良好,但在网上它的行为是这样的.主页链接的 href 值就是:$this->baseUrl()

check out this website www.fltdata.com. For some reason the home link no matter what page you go on instead of pointing to the home page it points to the current page. It works fine on my localhost but online its behaving like this. The href value of the home link is just : $this->baseUrl()

这里有什么问题..

=== 编辑===

好吧,我创建了一个助手,如下所示:

Well I have created a helper which is as below:

class Zend_View_Helper_BaseUrl
{
    protected $_baseUrl;

    function __construct()
    {
        $fc = Zend_Controller_Front::getInstance();
        $this->_baseUrl =  $fc->getBaseUrl();
    }

    function baseUrl()
    {
        return $this->_baseUrl;
    }
}

这是我猜每当我调用 $this->baseUrl 时会调用什么.这可能是问题所在 - 但是它在我的本地主机上运行正常,而不是在线,所以 - 一定是某种配置问题 - 我应该在哪里查看?

ANd this is I guess whats being called whenever I call $this->baseUrl. Could this be the problem - however it works okay in my localhost and not online so - must be some kind of configuration issue - where should I look?

推荐答案

如果不了解有关 ZF 设置和 e.h. 的更多详细信息,就很难判断这里出了什么问题.url 重写设置.Zend_Controller_Request_Http::getBaseUrl() 背后的逻辑 - 如果没有 baseUrl,您对 Zend_View_Helper_BaseUrl::baseUrl() 的调用将被代理到在前端控制器中显式设置 - 非常复杂,涉及 4 个不同的服务器变量(在确定当前请求 URI 的过程中还有一些).

It's hard to tell what's going wrong here without knowing more details about your ZF setup and e.h. the url-rewriting-setup. The logic behind Zend_Controller_Request_Http::getBaseUrl() - this is where your call to Zend_View_Helper_BaseUrl::baseUrl() will beproxied to if no baseUrl is set explicitly in the front-controller - is quite complex and involves 4 different server variables (and some more in the process of determining the current request URI).

克服这个问题最简单的方法可能是在引导程序的前端控制器上设置 baseUrl(相对于服务器根目录).如果你正在使用新的 Zend_Application-bootstrapping 你只需要添加

The easiest thing to overcome this problem would perhaps be to set the baseUrl (relative to the server root) on the front-controller in your bootstrap. If you're using the new Zend_Application-bootstrapping you'll just have to add

resources.frontController.baseUrl = "/subdir"

到您的配置.

编辑

您的助手或多或少类似于 ZF 附带的原始 baseUrl-helper.原始的也代理 Zend_Controller_Front::getBaseUrl().您使用哪个版本的 ZF?您是否有理由不使用随附的 baseUrl-helper?

Your helper more or less resembles the original baseUrl-helper shipped with the ZF. The original one also proxies to Zend_Controller_Front::getBaseUrl(). Which version of ZF do you use? Is there a reason why you don't use the shipped baseUrl-helper?

您是否尝试过在引导程序中明确设置 baseUrl?

Have you tried to set the baseUrl in your bootstrapping explicitly?

这篇关于Zend Framework $this->baseUrl() 总是返回当前页面 :( 为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆