Combining 2 domains

I have 2 domains (a .com and a .ca) that I want to combine using 1 Yii installation to serve slightly different content. What is the easiest way to combine them both into the .com and be able to use a subfolder (or subdomain) to manage the .ca information?

For example, domain.com and domain.com/ca/ (or domain.com and ca.domain.com).

We’ll have a session variable holding where the user is coming from so that they will be redirected to their own URL with their country’s information. We will query the session to know which content to display but I need to make sure each country can have it’s own URL to go to (domain.com for US and domain.com/ca/ for Canadian visitors).

Any ideas?

You don’t even need to redirect. Use the same docroot for both domains and have URL rules to determine the domain and render the correct content.

Yes. like Rodrigo suggested, one option is to use same docroot for both sites and then in code to determine which domain is used, and to server content for that domain. And if you are using relative urls, user will stay on domain, they came to at first(you can do it for example in components/Controller.php class)

Another option is to have two docroots, that share same yii installation, but I think first option is better and easier to maintain.