Zend Framework 2 Generating Route Url With Domain Name
Nothing more than this little line of code:
$homeUrl = $this->url(
'youRouteName',
array(/* your route params */),
array('force_canonical' => true)
);Of course, you need to call it within a code zone where you can invoke the URL helper. What you see above, assumes that you are in a .phtml file invoked by a controller’s action.