Multiple Yii Apps Under Single Domain

I’m wondering if anybody else has had a similar issue to what I’m having at the moment.

I have a domain, say www.example.com

I have 2 websites I wish to run from this domain, so I figure I could use Apache’s mod_alias. Here’s what I have:

[size="2"]Yii website installed to /path/to/website1[/size]

[size="2"]Yii website installed to /path/to/website2[/size]

[size="2"]In Apache, I have set up aliases as such:[/size]

    ServerName www.example.com





    DocumentRoot "/path/to/website1"





    Alias "/w1" /path/to/website1


    Alias "/w2" /path/to/website2


    <Directory /path/to/website1>


            Options FollowSymLinks +ExecCGI +Includes


            AllowOverride All


            DirectoryIndex index.html index.php


    </Directory>





    <Directory /path/to/website2>


            Options FollowSymLinks +ExecCGI +Includes


            AllowOverride All


            DirectoryIndex index.html index.php


    </Directory>

[size="2"]All is well, and I can get both websites to open their homepages with the links:[/size]

www.example.com/w1

www.example.com/w2

But, as soon as I click anything on website2 it just loads website1’s homepage. If I remove the “DocumentRoot” line, then it fails completely because it tries to use the main Apache DocumentRoot rather than the VirtualHost, and it says:

/var/www/html/path doesn’t exist. It’s trying to hit /var/www/html/path/to/website1/index.php which obviously doesn’t exist.

I hope I explained that properly, and that somebody may have come across this problem before. Can anybody help point me in the right direction please?

how about letting both .htaccess files in /path/to/website1 and /path/to/website2 deal with the requests invoking the apropriate index.php file.

this way you are exempt of any additiona virtualhost configuration settings.

does it work for you ?

I had .htaccess files in both sites pointing to the correct index.php. There’s only 1 VirtualHost, with 2 Aliases in there for the 2 different sites.

That is what I meant … strip the aliases and both .htaccess files should take care of the job.

given you have:

/public_html/.htaccess

/public_html/site1/.htaccess

/public_html/site2/.htaccess

whenever the is a request for any file under /public_html/site2/ , /public_html/site2/.htaccess will have priority and the same goes for files under /public_html/site1/ and /public_html/site1/.htaccess

so as long as you have a different entry point file index.php and respective protected/config/main.php it should work fine.