Sometimes, you need to be able to retrieve the current server url / domain from within your application dynamically. Doing so allows you to easily move code base from domain to domain without too many things going horribly wrong.
There are 2 places within ZendFramework you might need to do this. The first is from within the controller action, and the second is from within the view.
Here's how to get the Server URL in ZendFramework from within the controller:
PHP Code:
<?php
class IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $url = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost();
    }
}
Here's how to do it from within the view:
PHP Code:
<?php
echo $this->serverUrl();
?>

Payal commented on Oct 21st 2013