ZF2:Zend Framework 2 完整 URL,包括主机名 [英] ZF2: Zend Framework 2 Full URL including host name
本文介绍了ZF2:Zend Framework 2 完整 URL,包括主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我看来,我需要绘制完整的 URL.像这样:
In my view I need to draw full URL. Like this:
http://hostename.com/default/url
当我尝试使用 $this->url('default', array(1,2,3))
我只得到 /index/get/
.是否有任何 Zend 方法来获取主机名,或者我必须使用 $_SERVER['HTTP_HOST']
代替?
When I try to use $this->url('default', array(1,2,3))
I get only /index/get/
. Is there any Zend method to het host name or I have to use $_SERVER['HTTP_HOST']
instead?
推荐答案
您可以在路由器上使用选项 force_canonical
.所有路由选项都进入 url helper 的第三个参数:
You can use the option force_canonical
on the router. All router options go into the third parameter of the url helper:
url($route, $params, $options)
所以你可以这样做:
$this->url('myroute', array('id' => 123), array('force_canonical' => true))
这篇关于ZF2:Zend Framework 2 完整 URL,包括主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文