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

查看:91
本文介绍了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的更多详细信息的情况下,很难说出这里出了什么问题.网址重写设置. 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-帮手.原始版本也代理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天全站免登陆