Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract the full url (subdomain,domain and directories) with ZF?

Is there a way, using the functionality in ZF, to get the full url
(http[s]::/xxx.yyyy.ddd/ggg/hhh)

I am currently in?
baseUrl() will only give me the path, not the domain and sub domain.

I know how to extract it from the $_SERVER, trying to avoid that.

like image 912
Itay Moav -Malimovka Avatar asked May 18 '09 03:05

Itay Moav -Malimovka


1 Answers

Use getRequest() method of your controller to get an instance of Zend_Controller_Request_Http object. then try the getHttpHost() method of the request object. so in your controller, it would be like this:

$hostName = $this->getRequest()->getHttpHost();

Construct your full URL like the following:

$this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getRequestUri();
like image 55
farzad Avatar answered Oct 22 '22 05:10

farzad