Separate Yii app in subdirectory

Hi folks,

I have a working Yii app which has resides in the document root of the hosting account, all working happily at the primary domain.

Now I want to add a development version. I want to refer to a Yii app located in the /dev directory of the same account.

To clarify, here’s how I want things to work: shows a self contained app which resides at the document root (e.g. /http_docs/) shows another self contained app which resides at /http_docs/dev/

There is no overlap between these applications - i.e. they use different databases, and are completely separate implementations of Yii, yet the virtual server on the hosting account does not distinguish between the two domains - they both resolve to the same directory on the host.

I want the app on the dev. subdomain to be accessible without /dev in the path. So I am trying to pull the /dev out of the href and src attributes wherever they appear. I seem to have been successful with the href in the <a> tags, as all my links are appearing correctly (i.e. as opposed to; however all my css files are still being linked to at /dev/css rather than just /css.

In my main config file, I have the following for urlManager:










The baseUrl specification there seems to have applied correctly to the createUrl() method, however, where is the best place to call Yii::app()->setBaseUrl() for the other URLs that don’t go thru the urlManager?

It is on a Zeus server, which means standard Apache rewrites aren’t applicable. However I am generally capable of writing the rewrite rules, and the site is working quite well in spite of this single hiccup.

Hi M Wotton,

You have probably figured out the issue with this topic but seeing there is no answer I figured I would answer the topic. Upon investigating Yii I found that setting baseUrl in the UrlManager only rewrites url’s that use CreateUrl() which is used for CHTML:link (note: CreateAbsoluteUrl doesn’t get changed by UrlManager), so as you pointed out it won’t change the link for asset files and the HomeUrl which is used in the breadcrumb and home redirects to change the baseUrl for all of the items you have to add a attribute to the parent Class of those classes which is the “request” component

so adding this will fix your issue





The best way would be to keep these separate as in /production and /dev and have two virtualhost entries. This also avoids any potential for problems occurring during deployment to dev from version control interfering with the live site.

I’m guessing your host must be limiting you to one virtualhost?

Maybe this wiki will help you.