How can i get this base url
http://localhost/Symfony/web/app_dev.php/
OR
http://localhost/Symfony/web/app.php/
or
http://localhost/Symfony/web/
(base url)
in symfony2 config file? can't find at symfony website.
How can i get this base url
http://localhost/Symfony/web/app_dev.php/
OR
http://localhost/Symfony/web/app.php/
or
http://localhost/Symfony/web/
(base url)
in symfony2 config file? can't find at symfony website.
$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
$hostName = $request->server->get('HTTP_HOST');
$baseDirectory = "";
if(!empty($this->container->get('router')->getContext()->getBaseUrl())){
$baseDirectory = str_replace('app_dev.php', '', $this->container->get('router')->getContext()->getBaseUrl());
}
$rootUrl = $protocol.$hostName.$baseDirectory;
Hmm... check this:
$base = $this->getRequest()->getSchemeAndHttpHost();
or in oldest version (I don't remember when was the change):
$request = $this->getRequest();
$scheme = $request->getScheme();
$host = $request->getHttpHost();
$base = sprintf('%s://%s', $scheme, $host);