Yii::getPathOfAlias(‘webroot’) is return webroot path. How i can get webroot url?
Yii::getPathOfAlias(‘webroot’) is return webroot path. How i can get webroot url?
Yii::getPathOfAlias(‘application’)
Yii::app()->baseUrl
This returns the root url (where the entry script is)
So, you may use
Yii::app()->getBaseUrl(true)
to get an Absolute webroot url, and strip the http[s]://
thank you very much tof
hi, i have a url problem too.
my application is under: C:\xampp\htdocs\yii\basapp\protected
in protected folder, i create a folder named reports.
in the site/pages/about.php, i need to access the reports folder
i wrote something like this:
$url = Yii::app()->getBaseUrl(true) . ‘/reports’;
<a href=’<?php echo $url;?> '> reports </a>
but this link gaves me an error, unable to resolve this request.
how to solve this problem?
In this case,unable to resolve this request is because there is no reports controller found or under reports folder there is no index.php found.
See more details about Path Alias at
http://www.yiiframework.com/doc/guide/1.1/en/basics.namespace#root-alias
You can try to specify baseUrl in main.php as your want.