問(wèn)題描述
查看本網(wǎng)站 www.fltdata.com.出于某種原因,無(wú)論您訪問(wèn)哪個(gè)頁(yè)面,主頁(yè)鏈接都不是指向主頁(yè),而是指向當(dāng)前頁(yè)面.它在我的本地主機(jī)上運(yùn)行良好,但在網(wǎng)上它的行為是這樣的.主頁(yè)鏈接的 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()
這里有什么問(wèn)題..
=== 編輯===
好吧,我創(chuàng)建了一個(gè)助手,如下所示:
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;
}
}
這是我猜每當(dāng)我調(diào)用 $this->baseUrl 時(shí)會(huì)調(diào)用什么.這可能是問(wèn)題所在 - 但是它在我的本地主機(jī)上運(yùn)行正常,而不是在線,所以 - 一定是某種配置問(wèn)題 - 我應(yīng)該在哪里查看?
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?
推薦答案
如果不了解有關(guān) ZF 設(shè)置和 e.h. 的更多詳細(xì)信息,就很難判斷這里出了什么問(wèn)題.url 重寫(xiě)設(shè)置.Zend_Controller_Request_Http::getBaseUrl()
背后的邏輯 - 如果沒(méi)有 baseUrl
,您對(duì) Zend_View_Helper_BaseUrl::baseUrl()
的調(diào)用將被代理到在前端控制器中顯式設(shè)置 - 非常復(fù)雜,涉及 4 個(gè)不同的服務(wù)器變量(在確定當(dāng)前請(qǐng)求 URI 的過(guò)程中還有一些).
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).
克服這個(gè)問(wèn)題最簡(jiǎn)單的方法可能是在引導(dǎo)程序的前端控制器上設(shè)置 baseUrl
(相對(duì)于服務(wù)器根目錄).如果你正在使用新的 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"
到您的配置.
編輯
您的助手或多或少類(lèi)似于 ZF 附帶的原始 baseUrl
-helper.原始的也代理 Zend_Controller_Front::getBaseUrl()
.您使用哪個(gè)版本的 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?
您是否嘗試過(guò)在引導(dǎo)程序中明確設(shè)置 baseUrl
?
Have you tried to set the baseUrl
in your bootstrapping explicitly?
這篇關(guān)于Zend Framework $this->baseUrl() 總是返回當(dāng)前頁(yè)面 :( 為什么的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!