createUrl on subdomain

Hi,

I have following UrlRules:


  'rules' => array(

                'http://<nick:\w+>.mydomain.com' => 'users/showuser',

                'photo/<pid:\d+>/<title:.+>' => 'photo/view',

Now, I’m trying to access url nick.mydomain.com => action ‘users/showuser’ works fine.

But! All links generated by createUrl will have subdomain ‘nick.’.

Link:


http://mydomain.com/photo/555/hello-world 

become


http://nick.mydomain.com/photo/555/hello-world

How to avoid it?

I need, that all my links point to my primary domain, not including subdomains.

Well, your links will have nick. in front of the domain name if you are looking at them from http://nick.domain.com, but if you are looking at them from http://domain.com they look just fine, right ?

Try to set the base url manually in your config file to your domain name, something like:




'baseUrl' => 'http://www.domain.com',



Also, maybe you need to slightly alter your rules, like:




'http://<nick:[^www]\w+>.mydomain.com' => 'users/showuser',



to be able to still use www.domain.com .

And move the subdomain rule at the bottom of your rules list.

Also, try createAbsoluteUrl() too and see the behavior of that method in comparison with createUrl()

Dunno if this is going to fix your issue, but worth a try.