Default Controller for root


Please the following guide:

OK I had a look at that but I still can’t figure out what the rule should be.


Cheers, that works fine, however I would need to create seperate rules for each of my pages at root level.

Is there any way to make all root page requests go to the SiteController?

not sure if this will work but i’d try


Are you extending your other controllers from SiteController? If you extend from SiteController, any class-specific properties and action methods in SiteController will be inheirited by your other controllers. So, you can put common code that needs to be shared among your other controllers in SiteController. You could have other controllers to extend from if you need them (e.g., an AdminController for your Admin modules).

‘*’=>‘site’ did not work I’m afraid…

cmx - I’m not extending any of my controllers from SiteController. I’m basically just building the site with the default skeleton that Yii provides.

SiteController works fine for the root when you don’t specify the index file, i.e:


but does not work for /

Anyone able to advise?

Can someone help me with this please? :)

check this page to see how to configure urlMagager component.


I have seen that page already but I cannot figure out how to make it redirect all /site/ requests to root.

Anyone able to advise?

specify a rule for each of your routes

You can use

'' => 'my/route'

for a root request ("/"). No need for "/index.html" then. Other than that you should specify each route like already noted.

Well / already goes to the root page, but / does not.

Essentially I just want to put a bunch of files in to a default ‘root’ folder and for those pages to display without me having to specify the route for each and every file.

So "/index.html" should point to "site/index", "/about.html" should point to "site/about" and so on?

So in other words I have to create a seperate rule for each and every page, even if they are just static pages?

If they’re static (not using Yii), try htaccess or something. Otherwise you may take a look at “Parameterizing Routes” at Maybe that can help you.

This is strange. I don’t understand why I can put pages in the “site” folder and I don’t need to create any rules for them. There should be a “root” folder which handles all root page requests.

Well I’m still not sure what you’re trying to do. Why not simply put the routes into your config? Then you can also make use of createUrl() function instead of hardcoding the links into your page.

Or are there like 100 "root"-pages?? Then there should be a better solution. Otherwise specify every route?