Prevent Urlmanager When Load A Module

I know that the components of config/main.php loaded before controller or modules do that

But I have a special issue.

I want seo url for front-end site (by urlManager => array(‘class’=>‘MyUrlManager’) but I don’t want it for modules like admin!

How could load urlManager only when haven’t a special GET parameter like ?

In other cases urlManager loaded normally

Thanks a lot!


Hi KonApaz,

It seems impossible to me, because the url manager is bi-directional: creating URL and interpreting URL.

Isn’t it something you can do with the rules of the url manager? I mean, the rules for the frontend and those for the admin pages altogether in the configuration of the manager …

Dear Friend

We have to fully agree with our friend softark’s opinion on this.

I tried to fork the urlMangar logic in onBeginRequest event of main application.

I failed.

The following works…

But I am not happy with this hack.




if(isset($_GET['r']) && substr($_GET['r'],0,6)=="admin")

	$config=dirname(__FILE__).'/protected/config/custom.php';//loading different configuration file. 



Hi softark

for security reasons I would avoid it, But there is another one problem,

I set aldeady rule to set in url the language before all (for better seo)

All urls are in this format









I want to exclude the secured modules for that!

In addition if i set a rule like ‘securedModule’=>‘securedModule/controller/index’ and

something wants redirect (like user/login) then a rule with language prefix will be applied like en/site/login (I don’t want it too)

So I decided to exclude entire rules from secured modules.

A solution that I found is loading another config/main.php (like config/secured.php)

and check in main index.php of my application the ‘r’ value prefix and loads the appropriated config file.

what do you think about it ?

Thanks softark for your response :)

I see.

So you two have reached the same solution. :)

One thing I don’t understand is “security reasons”. I don’t think it could be a security issue. What do you have in mind for that?

And, another thing is a fact that we may sometimes want to create a front-end URL in the secured module, and vice versa. By switching url managers we have to use hard-coded url strings for those cases.

I think you could make a set of url rules for the secured module (and one for site/login) and position them before the general rules that generates language prefixed urls.

Hi softark and seenivasan

I thought exactly the seenivasan’s way!

I see other members of Yii has the same issue

About “security reasons” I mean if somebody (like hacker) find the match pattern urlmanager roles for front-end system then he has the url’s pattern of back-end! Nobody want it! In contrast we want seperatly manage of secured modules (like administrator)

In addition I thing that is not very professional for a site to has seo url in admin or secured modules

thanks both softark and seenivasan for response! :)

If someone has any other option please post it!