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: www.mydomain.com/mysubdirectory

I want the users to only see: www.mydomain.com

I have a .htaccess forwarding any requests from www.mydomain.com to www.mydomain.com/mysubdirectory

This works BUT Yii is generating menu links that point to: www.mydomain.com/mysubdirectory/controller/action

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

Cheers

Pete

try to force baseUrl param in urlManager component:

protected/config/main.php




'componenets'=>array(

   'urlManager'=>array(

      'baseUrl'=>'http://www.mydomain.com',

      ...

...



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 www.mydomain1.com and www.mydomain2.com to both point to www.mydomain.com/myapp/

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:




'<route:.*>'=>'myapp/<route>'



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

Cheers

Pete

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:

http://muhammadatt.tumblr.com/post/83149364519/modifying-a-yii-application-to-run-from-a-subdirectory

I have two websites (podcast.newsradio1620.com & podcast.catcountry987.com) 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/