my website has several yii applications.
some of which are accessed by subdomains, and others by path alias. e.g.
app1: user.abc.com (subdomain)
app2: www.abc.com/admin (path alias)
in app2, i create a link to http://user.abc.com/?r=account/login
<a href="http://user.abc.com/<?php $this->createUrl('account/loigin')?>">Login</a>
but the result is http://user.abc.com/…=account/login.
i know the reason is that the baseUrl of app2 is /admin,
but how could i resolve it? thx
The createUrl() method is really useful when inserting links in one application, but it’s not that useful when pointing outside.
Instead of trying to build links with application tools, I recommend you to put them explicitly into views (only when linking to different hosts).
<a href="http://user.abc.com/?r=account/login/"> is the expected URL? Then insert that.
but when i change the url mapping rule, the link will be incorrect…
I know, but two applications cannot see the other one’s mapping rules, can they?
So I suggest to reorganize your apps into modules, so you can use createUrl().
Otherwise, you will need to extend this method and store all your mapping rules in every application (which is redundancy and maintainability nightmare).