Denis Kulagin
Denis Kulagin

Reputation: 8916

How to run multiple subdomains on the same Yii engine?

I would like to structure the website not using url-folders, but rather subdomains:

not my.com/xyz/page1

but rather xyz.my.com/page1

they would share the same design, same layouts and reuse large part of the codebase.

Is it possible to configure URL manager so that both main domain and a subdomain are served using the same codebase?

P.S. Yii version is 1.1.

Upvotes: 0

Views: 276

Answers (1)

raczmedia
raczmedia

Reputation: 11

We use this setup at work actually. What you do is parse your url in the index.php file. Break it up. Based on the first word up until the dot... that can be the name of your folder in the protected/config folder. Make a copy of all of the files currently in the config folder and put it into this new one. So the file structure is /config/subdomain/allfiles here... and /config/subdomain2/allfiles... etc etc. And make sure that the yii app gets made using the correct config by oarsing the url and using the subdomain to locate the folder. You can use different params... dbs, etc etc. But the same code.. and file base for all.

Upvotes: 1

Related Questions