I have a Yii project deployed on a server into a separate folder. That is it resides in the webroot/projectfolder. All setup is done and project works ok when accessed via URL http://server.domain/projectfolder. What I want to do next is to make the project accessible from http://server.domain without moving the entire project. I thought, it is enough to edit relative paths in the Yii’s index.php file and move the file one level up from projectfolder. Unfortunately, after doing so, I encountered a problem with different assets. Home page shows up without css-style applied, because css-files can not be found. The project searches them in webroot/css instead of webroot/projectfolder/css. Also it tries to access non-existing webroot/assets folder (whereas it remains in webroot/projectfolder/assets).
So, the question is how to change Yii’s project config for this environment: index.php is in the webroot, and the rest of the project is in a subfolder.
P.S. I found the related article here. But it describes a bit more complicated case than I want. I’d like to adjust all the stuff in more simple way, if possible.
Apparently, this does not change the project URL - all its stuff will still be accessible in the same way as at the moment, that’s from inside the folder.
'components'=>array(
//assets, see http://www.yiiframework.com/doc/api/CAssetManager
'assetManager'=>array(
// change the path on disk
'basePath'=>dirname(__FILE__).'/../../assets/',
// change the url
'baseUrl'=>'/web/assets/'
),
)
Actually, no. I want to leave the project (including assets and css) ‘as is’ in its subfolder, but does bootstrap it from webroot. If I understand correctly, we define in .htaccess that all requests which are not files and directories are passed to index.php, and then it should pick up Yii core, controllers, views, resources, etc based on the given configuration. It works when index.php resides in the subfolder, but it breaks when the index.php moved outside the subfolder and path for config is changed accordingly:
It looks like I should possibly add something to the config itself. ‘basePath’ should not change, because config/main.php is still in the same relative position to the ‘protected’ folder as usual. I’m not sure if BaseURL could help.