Set baseUrl based on host name


I have a site that is accessible at (A)

I also want to use an SSL proxy where my site is accessible at (B)

So I need urlManager->baseUrl to be ‘’ in the case of (A) and to be ‘’ in the case of (B). How to accomplish that?

I there an option I did not know?

I could overwrite CUrlManager, but where is the class specified that will be used?

Thanks a lot





Thanks a lot. That did the trick. Almost.

As it is a SSL proxy, the requests are still made to the server (A).

With my own urlManager I can change the links created.

With my own assetManager I can set the correct asset links.

I now found that CHtml uses app()->getRequest->getUrl() as well, so I need to modify that.

Otherwise form data would be send to instead of https://ssl.example…

Unfortunately, it seems there is no way to use another class instead of CHtml without changing CHtml:: calls in every view. Or is there?

Maybe change CHttpRequest.getUrl() method then? It is an application’s request component.

For the archive, here is my solution.

All you have to do is to override CHttpRequest::getRequestUri() [for request resolution], ::getScriptUrl() [for request resolution and CHtml::link()], and ::getUrl() [for CHtml::form()]

urlManager and assetManager can stay as they are, they will use one of the three functions above.

I have separate frontend and backend in my cms project in yii.

now i have to keep my url like

/mysite/index.php/site/index - for front

/mysite/admin.php/site/index.- for admin

but in admin if i click on any other link then the url is

/mysite/site/index - the admin.php disappears

and the error is the requested url is not found on this server.

so how to set the url?? :mellow: