English 中文(简体)
在Kkohana路线上的严格空白应用
原标题:Strictly blank application uri in kohana route


I m trying to make a route rule to make my request to the main page in kohana. It s sth of this kind: http://my_site/
And got into trouble here. In docs they write i can make this or that, lots of variants, but no example for mine. Simply saying if i try to do this way

Route::set( main/index ,   )
    ->defaults(array(
         controller  =>  main ,
         action      =>  index ,
    ));

然后,如果一字面写: i 链接到同一页。 如果是,

Route::set( main/index , null)
    ->defaults(array(
         controller  =>  main ,
         action      =>  index ,
    ));

No result again, uri callback should have a valid value.
In official manual they suggest this variant

Route::set( default ,  (<controller>(/<action>(/<id>))) )
->defaults(array(
     controller  =>  welcome ,
     action      =>  index ,
));

But i need a rule with a strict match i.e. just http://my_site/, not http://my_site/(<controller>(/<action>(/<id>)))
Is there a way to help me out from this without rewriting Route class?
Thanks in advance

最佳回答

页: 1 你们想要做的是使用<代码>ur方法>::Route:url(主要/指数)。 这将给你一个已经通过<>Url:site的圆顶。

问题回答
Route::set( main/index ,   )
    ->defaults(array(
         controller  =>  main ,
         action      =>  index ,
    ));

如果我确信这条路是在任何可能与空洞连接的其他航道之前铺设的,那么我就只能为我工作。 路线按添加顺序检查。

如果你想要知道贵国的路线(开发服务器)与否,你就可以将违约控制人设定为像假象这样的非现存控制人。 然后,Kohaana wil扔下了Http_Exception_404,而例外手将给你一个错误的网页。 (如果土耳其没有,就会出现科哈纳错误) 在该网页上点击了头几个痕迹的线索。 那么,你们就应当看到这样的东西:

object Request(18) {
    ...snip...
    protected _route => object Route(5) {
        protected _callback => NULL
        protected _uri => string(0) ""
        protected _regex => array(0) 
        protected _defaults => array(1) (
            "controller" => string(5) "bogus" // the non-existing bogus controller default
        )
        protected _route_regex => string(6) "#^$#uD"
    }
    ...snip...
}

I got the above by placing the following route before I add any other route (which could match that uri too):

Route::set( main/index ,   )
    ->defaults(array(
         controller  =>  bogus ,
    ));

并确保其他路线不会使用主要/指数名称,因为它会超过老年人。 实际上,我只看了Route:uri()和猜测。 法定路线(有斜线的航道;或(其中的))应交回目前的航道。 由于空洞是一条固定路线,结果路线是:这条路总是只有东道国。 这表明,你在放弃主线/指数路线时,把安放到空洞。

另外,当把民族解放军用作一条路线的里程时,这条路被假定为来自海滩,而你最后是在没有从海滩上走一条空洞的路。





相关问题
Rails: Proxy Pass?

I ve got a web-app that I want to migrate to Rails, which is currently just plain HTML with an Apache proxy to another server, running a custom database/webserver that serves the site s dynamic ...

MVC routing is not handling one of my directories

I m using ASP.NET MVC with IIS 7.0. I ve got 404 errors hooked up fine through my Application_Error override. In addition to "Controllers", "Models", "Helpers" etc. I have a directory called Files ...

Ruby on Rails conditional routing

I have a site listing many jobs, but I also want each account to be able to access its jobs in one place. Thus, I am using these routes: map.resources :jobs map.resource :account, :has_many => :...

Clean URL s using OpenCart s router class

How do you write clean URL s in OpenCart using their built in Router class? Here is my .htaccess file: RewriteEngine On RewriteRule ^(system) - [F,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...

subdomain routing to multiple controller issue

I have a site: www.mydomain.com where we have administrative controls hidden away from normal customer view. I would like to only access the administrative features under a subdomain such as admin....

Can controller names in RESTful routes be optional?

With a standard map.resource routing mechanics and several nested resources the resultant routes are unnecessarily long. Consider the following route: site.org/users/pavelshved/blogs/blogging-horror/...

Help with rails routes

Im having a little trouble setting up routes. I have a users controller/model/views set up restfully so users is set up to be a resource in my routes. I want to change that to be usuarios ...

热门标签