Reputation: 85
How to check in index action If I am at www.sample.com/test not at www.sample.com/test/qqqq or www.sample.com/test?testget=fdfdf&testget2=fdfdfdf or at others sites just only at www.sample.com/test ?
Upvotes: 0
Views: 729
Reputation: 785
In a view you can use
echo $this->serverUrl(true);
You can also use view helpers in a controller
$viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
$myHelper = $viewHelperManager->get('serverUrl');
Upvotes: 0
Reputation: 174
In zf1 this was straightforward with applicationPath or rootPath but in zf2 this has changed.
Found more information here http://samminds.com/2012/08/why-root_path-is-not-needed/
Hope it helps
Upvotes: 0