How do run a Yii app in a masked subdirectory?

Hi and thanks in advance for any help,

I have a yii app installed in:

I want the users to only see:

I have a .htaccess forwarding any requests from to

This works BUT Yii is generating menu links that point to:

How do I set up my config to avoid any appearance of "mysubdirectory"?



try to force baseUrl param in urlManager component:







Thanks for super speedy response! That works but my next problem is how best to get this running for multiple domains:

i.e. I want and to both point to

I don’t think your solution will work in this case, any other ideas?

If they’re both going to be showing the same data then your search rankings will take a hit from duplicate content.

In any case, is there anything to stop you from using a simple route? Something like:


That would take care of any links that you create.

Thanks, I’ll give that a try, the reason I’m trying to do this to allow me to run the same codebase on different sites but serve different content based on the domain.

If anyone’s tried this before I’d love any tips they could give me



I found this post attempting to do something similar. I was able to get it to work by moving the Yii entry script (index.php) and the default .htaccess up from the subdirectory to the webroot (so that they reside directly under public_html). Once you move index.php and .htaccess to the root directory, all web requests will be routed directly to index.php under webroot (rather than to the subdirectory), thus eliminating the /subdirectory part of the url.

After you move the files, you will need to edit index.php to update the references to the yii.php file (under the Yii framework directory) as well as the Yii config file (main.php). Lastly, you will need to move the assets directory to directly the webroot, since by default, Yii expects the assets directory to be located in the same location as the entry script).

That should be all you need to do, but if you need more details, I describe the approach fully here:

I have two websites ( & that use the same site to function. The only difference is the index.php file sets a theme and db connection based on the request containing newsradio or catcountry. I have a basic config file that I merge_array with station specific config.

The web server has two virtual hosts that both point to the index.php file/