0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! It was my thought on how to solve it with a hand-made bicycle. Good to know it's already working in production for someone :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.