Custom Domain Mapping Question

Hi there, I am trying to allow my users to setup custom domain via Yii (1.1.14). i.e. -> Does anyone have any experience doing this in Yii? I am not sure what is the best approach and I have tried the following.

In my urlManager rules, I already have a bunch of rules that handle username in the subdomain. For example,



'http://<user:[a-zA-Z0-9_-]+>' => 'controller/action/username/<user>',


Then, I added a new urlmanager rule:



 'class' => 'application.components.ExampleUrlRule',



And in the parseUrl() function, I simply look up the custom url in DB and get the corresponding username. Then I tried to cheat a little by simply updating the $request->hostInfo to Then I run $manager->parseUrl($request) again so it re-uses my original rules which handles username in the subdomain.

This seems to be partially working. However, it doesn’t work when I am making an AJAX call to the custom domain name. I have a feeling it’s some sort of CORS restriction.

So again, my questions are:

  1. What is the suggested approach for doing custom domain masking for users?

  2. How do you handle cross domain AJAX calls with custom domains?

  3. How do you handle sessions correctly with custom domains?