Default Controller for root

It seems the default controller is SiteController, this means that I can only access root pages by going to /mysite.com/site/index.html rather than /mysite.com/index.html (I put my root pages in the ‘site’ views folder).

How can I change this?

Hi,

Please the following guide:

http://www.yiiframework.com/doc/guide/topics.url

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


'index'=>'site/index',

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


'*'=>'site'

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:

/mysite.com/

but does not work for /mysite.com/index.html

Anyone able to advise?

Can someone help me with this please? :)

check this page to see how to configure urlMagager component. http://www.yiiframework.com/doc/guide/topics.url

Hi,

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 /mysite.com/ already goes to the root page, but /mysite.com/index.html 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 http://www.yiiframework.com/doc/guide/topics.url 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.