Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework $this->baseUrl() always returns the current page :( why

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()

Whats wrong here..

=== EDIT===

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;
    }
}

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?

like image 392
Ali Avatar asked Aug 26 '09 06:08

Ali


1 Answers

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).

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"

to your configuration.

EDIT

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?

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

like image 150
Stefan Gehrig Avatar answered Oct 06 '22 00:10

Stefan Gehrig